GDAL

Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
GDALInConstructionAlgorithmArg Class Reference

Technical class used by GDALAlgorithm when constructing argument declarations. More...

`#include <gdalalgorithm_cpp.h>`

Inheritance diagram for GDALInConstructionAlgorithmArg:

## Public Member Functions
template<class T >
| GDALInConstructionAlgorithmArg (GDALAlgorithm *owner, const GDALAlgorithmArgDecl &decl, T *pValue)
| Constructor.
| ~GDALInConstructionAlgorithmArg () override
| Destructor.
GDALInConstructionAlgorithmArg & | AddAlias (const std::string &alias)
| Add a documented alias for the argument.
GDALInConstructionAlgorithmArg & | AddHiddenAlias (const std::string &alias)
| Add a non-documented alias for the argument.
GDALInConstructionAlgorithmArg & | AddShortNameAlias (char shortNameAlias)
| Add a shortname alias for the argument.
GDALInConstructionAlgorithmArg & | SetPositional ()
| Alias for GDALAlgorithmArgDecl::SetPositional()
GDALInConstructionAlgorithmArg & | SetRequired ()
| Alias for GDALAlgorithmArgDecl::SetRequired()
GDALInConstructionAlgorithmArg & | SetMetaVar (const std::string &metaVar)
| Alias for GDALAlgorithmArgDecl::SetMetaVar()
GDALInConstructionAlgorithmArg & | SetCategory (const std::string &category)
| Alias for GDALAlgorithmArgDecl::SetCategory()
template<class T >
GDALInConstructionAlgorithmArg & | SetDefault (const T &value)
| Alias for GDALAlgorithmArgDecl::SetDefault()
GDALInConstructionAlgorithmArg & | SetDefault (const char *value)
| Alias for GDALAlgorithmArgDecl::SetDefault()
GDALInConstructionAlgorithmArg & | SetMinCount (int count)
| Alias for GDALAlgorithmArgDecl::SetMinCount()
GDALInConstructionAlgorithmArg & | SetMaxCount (int count)
| Alias for GDALAlgorithmArgDecl::SetMaxCount()
GDALInConstructionAlgorithmArg & | SetDisplayHintAboutRepetition (bool displayHint)
| Alias for GDALAlgorithmArgDecl::SetDisplayHintAboutRepetition()
GDALInConstructionAlgorithmArg & | SetPackedValuesAllowed (bool allowed)
| Alias for GDALAlgorithmArgDecl::SetPackedValuesAllowed()
GDALInConstructionAlgorithmArg & | SetRepeatedArgAllowed (bool allowed)
| Alias for GDALAlgorithmArgDecl::SetRepeatedArgAllowed()
template<typename T , typename... U, typename std::enable_if<!std::is_same_v< T, std::vector< std::string > & >, bool >::type = true>
GDALInConstructionAlgorithmArg & | SetChoices (T &&first, U &&...rest)
| Alias for GDALAlgorithmArgDecl::SetChoices()
GDALInConstructionAlgorithmArg & | SetChoices (const std::vector< std::string > &choices)
| Alias for GDALAlgorithmArgDecl::SetChoices()
template<typename T , typename... U>
GDALInConstructionAlgorithmArg & | SetHiddenChoices (T &&first, U &&...rest)
| Alias for GDALAlgorithmArgDecl::SetHiddenChoices()
GDALInConstructionAlgorithmArg & | SetMinValueIncluded (double min)
| Alias for GDALAlgorithmArgDecl::SetMinValueIncluded()
GDALInConstructionAlgorithmArg & | SetMinValueExcluded (double min)
| Alias for GDALAlgorithmArgDecl::SetMinValueExcluded()
GDALInConstructionAlgorithmArg & | SetMaxValueIncluded (double max)
| Alias for GDALAlgorithmArgDecl::SetMaxValueIncluded()
GDALInConstructionAlgorithmArg & | SetMaxValueExcluded (double max)
| Alias for GDALAlgorithmArgDecl::SetMaxValueExcluded()
GDALInConstructionAlgorithmArg & | SetMinCharCount (int count)
| Alias for GDALAlgorithmArgDecl::SetMinCharCount()
GDALInConstructionAlgorithmArg & | SetHidden ()
| Alias for GDALAlgorithmArgDecl::SetHidden()
GDALInConstructionAlgorithmArg & | SetHiddenForCLI (bool hiddenForCLI=true)
| Alias for GDALAlgorithmArgDecl::SetHiddenForCLI()
GDALInConstructionAlgorithmArg & | SetHiddenForAPI (bool hiddenForAPI=true)
| Alias for GDALAlgorithmArgDecl::SetHiddenForAPI()
GDALInConstructionAlgorithmArg & | SetIsInput (bool isInput=true)
| Alias for GDALAlgorithmArgDecl::SetIsInput()
GDALInConstructionAlgorithmArg & | SetIsOutput (bool isOutput=true)
| Alias for GDALAlgorithmArgDecl::SetIsOutput()
GDALInConstructionAlgorithmArg & | SetReadFromFileAtSyntaxAllowed ()
| Alias for GDALAlgorithmArgDecl::SetReadFromFileAtSyntaxAllowed()
GDALInConstructionAlgorithmArg & | SetRemoveSQLCommentsEnabled ()
| Alias for GDALAlgorithmArgDecl::SetRemoveSQLCommentsEnabled()
GDALInConstructionAlgorithmArg & | SetAutoOpenDataset (bool autoOpen)
| Alias for GDALAlgorithmArgDecl::SetAutoOpenDataset()
GDALInConstructionAlgorithmArg & | SetMutualExclusionGroup (const std::string &group)
| Alias for GDALAlgorithmArgDecl::SetMutualExclusionGroup()
GDALInConstructionAlgorithmArg & | AddMetadataItem (const std::string &name, const std::vector< std::string > &values)
| Alias for GDALAlgorithmArgDecl::AddMetadataItem()
GDALInConstructionAlgorithmArg & | SetDatasetType (GDALArgDatasetType datasetType)
| Alias for GDALAlgorithmArgDecl::SetDatasetType()
GDALInConstructionAlgorithmArg & | SetDatasetInputFlags (int flags)
| Alias for GDALAlgorithmArgDecl::SetDatasetInputFlags()
GDALInConstructionAlgorithmArg & | SetDatasetOutputFlags (int flags)
| Alias for GDALAlgorithmArgDecl::SetDatasetOutputFlags()
GDALInConstructionAlgorithmArg & | AddAction (std::function< void()> f)
| Register an action that is executed, once and exactly once, if the argument is explicitly set, at the latest by the ValidateArguments() method.
GDALInConstructionAlgorithmArg & | AddValidationAction (std::function< bool()> f)
| Register an action that is executed, once and exactly once, if the argument is explicitly set, at the latest by the ValidateArguments() method.
GDALInConstructionAlgorithmArg & | SetAutoCompleteFunction (std::function< std::vector< std::string >(const std::string &)> f)
| Register a function that will return a list of valid choices for the value of the argument.
GDALInConstructionAlgorithmArg & | SetIsCRSArg (bool noneAllowed=false, const std::vector< std::string > &specialValues=std::vector< std::string >())
| Register an action to validate that the argument value is a valid CRS definition.
GDALInConstructionAlgorithmArg & | SetUserProvided ()
| Alias for GDALAlgorithmArgDecl::SetUserProvided()
const GDALAlgorithmArgDecl & | GetDeclaration () const
| Return the argument declaration.
const std::string & | GetName () const
| Alias for GDALAlgorithmArgDecl::GetName()
const std::string & | GetShortName () const
| Alias for GDALAlgorithmArgDecl::GetShortName()
const std::vector< std::string > & | GetAliases () const
| Alias for GDALAlgorithmArgDecl::GetAliases()
const std::vector< char > & | GetShortNameAliases () const
| Alias for GDALAlgorithmArgDecl::GetShortNameAliases()
const std::string & | GetDescription () const
| Alias for GDALAlgorithmArgDecl::GetDescription()
const std::string & | GetMetaVar () const
| Alias for GDALAlgorithmArgDecl::GetMetaVar()
GDALAlgorithmArgType | GetType () const
| Alias for GDALAlgorithmArgDecl::GetType()
const std::string & | GetCategory () const
| Alias for GDALAlgorithmArgDecl::GetCategory()
bool | IsRequired () const
| Alias for GDALAlgorithmArgDecl::IsRequired()
int | GetMinCount () const
| Alias for GDALAlgorithmArgDecl::GetMinCount()
int | GetMaxCount () const
| Alias for GDALAlgorithmArgDecl::GetMaxCount()
bool | GetDisplayHintAboutRepetition () const
| Alias for GDALAlgorithmArgDecl::GetDisplayHintAboutRepetition()
bool | GetPackedValuesAllowed () const
| Alias for GDALAlgorithmArgDecl::GetPackedValuesAllowed()
bool | GetRepeatedArgAllowed () const
| Alias for GDALAlgorithmArgDecl::GetRepeatedArgAllowed()
bool | IsPositional () const
| Alias for GDALAlgorithmArgDecl::IsPositional()
const std::vector< std::string > & | GetChoices () const
| Alias for GDALAlgorithmArgDecl::GetChoices()
const std::vector< std::string > & | GetHiddenChoices () const
| Alias for GDALAlgorithmArgDecl::GetHiddenChoices()
std::vector< std::string > | GetAutoCompleteChoices (const std::string &currentValue) const
| Return auto completion choices, if a auto completion function has been registered.
std::pair< double, bool > | GetMinValue () const
| Alias for GDALAlgorithmArgDecl::GetMinValue()
std::pair< double, bool > | GetMaxValue () const
| Alias for GDALAlgorithmArgDecl::GetMaxValue()
int | GetMinCharCount () const
| Alias for GDALAlgorithmArgDecl::GetMinCharCount()
bool | IsExplicitlySet () const
| Return whether the argument value has been explicitly set with Set()
bool | HasDefaultValue () const
| Alias for GDALAlgorithmArgDecl::HasDefaultValue()
bool | IsHidden () const
| Alias for GDALAlgorithmArgDecl::IsHidden()
bool | IsHiddenForCLI () const
| Alias for GDALAlgorithmArgDecl::IsHiddenForCLI()
bool | IsOnlyForCLI () const
| Alias for GDALAlgorithmArgDecl::IsOnlyForCLI()
bool | IsHiddenForAPI () const
| Alias for GDALAlgorithmArgDecl::IsHiddenForAPI()
bool | IsInput () const
| Alias for GDALAlgorithmArgDecl::IsInput()
bool | IsOutput () const
| Alias for GDALAlgorithmArgDecl::IsOutput()
bool | IsReadFromFileAtSyntaxAllowed () const
| Alias for GDALAlgorithmArgDecl::IsReadFromFileAtSyntaxAllowed()
bool | IsRemoveSQLCommentsEnabled () const
| Alias for GDALAlgorithmArgDecl::IsRemoveSQLCommentsEnabled()
const std::string & | GetMutualExclusionGroup () const
| Alias for GDALAlgorithmArgDecl::GetMutualExclusionGroup()
const std::map< std::string, std::vector< std::string > > | GetMetadata () const
| Alias for GDALAlgorithmArgDecl::GetMetadata()
const std::vector< std::string > * | GetMetadataItem (const std::string &name) const
| Alias for GDALAlgorithmArgDecl::GetMetadataItem()
template<class T >
const T & | GetDefault () const
| Alias for GDALAlgorithmArgDecl::GetDefault()
bool | AutoOpenDataset () const
| Alias for GDALAlgorithmArgDecl::AutoOpenDataset()
bool | IsUserProvided () const
| Alias for GDALAlgorithmArgDecl::IsUserProvided()
GDALArgDatasetType | GetDatasetType () const
| Alias for GDALAlgorithmArgDecl::GetDatasetType()
int | GetDatasetInputFlags () const
| Alias for GDALAlgorithmArgDecl::GetDatasetInputFlags()
int | GetDatasetOutputFlags () const
| Alias for GDALAlgorithmArgDecl::GetDatasetOutputFlags()
template<class T >
T & | Get ()
| Return the value of the argument, which is by decreasing order of priority:
template<class T >
const T & | Get () const
| Return the value of the argument, which is by decreasing order of priority:
bool | Set (bool value)
| Set the value for a GAAT_BOOLEAN argument.
bool | Set (const std::string &value)
| Set the value for a GAAT_STRING argument.
bool | Set (const char *value)
| Set the value for a GAAT_STRING argument.
bool | Set (GDALDataType dt)
| Set the value for a GAAT_STRING argument from a GDALDataType It cannot be called several times for a given argument.
bool | Set (const OGRSpatialReference &)
| Set the value for a GAAT_STRING argument (representing a CRS) from a OGRSpatialReference It cannot be called several times for a given argument.
bool | Set (int value)
| Set the value for a GAAT_INTEGER (or GAAT_REAL) argument.
bool | Set (double value)
| Set the value for a GAAT_REAL argument.
bool | Set (GDALDataset *ds)
| Set the value for a GAAT_DATASET argument, increasing ds' reference counter if ds is not null.
bool | Set (std::unique_ptr< GDALDataset > ds)
| Set the value for a GAAT_DATASET argument.
bool | Set (const std::vector< std::string > &value)
| Set the value for a GAAT_STRING_LIST argument.
bool | Set (const std::vector< int > &value)
| Set the value for a GAAT_INTEGER_LIST argument.
bool | Set (const std::vector< double > &value)
| Set the value for a GAAT_REAL_LIST argument.
bool | Set (std::vector< GDALArgDatasetValue > &&value)
| Set the value for a GAAT_DATASET_LIST argument.
bool | SetDatasetName (const std::string &name)
| Set the value for a GAAT_DATASET argument.
bool | SetFrom (const GDALArgDatasetValue &other)
| Set the value for a GAAT_DATASET argument.
bool | SetFrom (const GDALAlgorithmArg &other)
| Set the value for another argument.
void | SetSkipIfAlreadySet (bool skip=true)
| Advanced method used to make "gdal info" and "gdal raster|vector info" to avoid re-opening an already opened dataset.
bool | SkipIfAlreadySet () const
| Advanced method used to make "gdal info" and "gdal raster|vector info" to avoid re-opening an already opened dataset.
bool | Serialize (std::string &serializedArg, bool absolutePath=false) const
| Serialize this argument and its value.

## Static Public Member Functions
static std::string | GetEscapedString (const std::string &s)
| Return an escaped string for argument serialization.

## Protected Attributes
GDALAlgorithmArgDecl | m_decl
| Argument declaration.
std::variant< bool *, std::string *, int *, double *, GDALArgDatasetValue *, std::vector< std::string > *, std::vector< int > *, std::vector< double > *, std::vector< GDALArgDatasetValue > * > | m_value {}
| Pointer to the value.
std::vector< std::function< void()> > | m_actions {}
| Actions.
std::vector< std::function< bool()> > | m_validationActions {}
| Validation actions.
std::function< std::vector< std::string >(const std::string &)> | m_autoCompleteFunction {}
| Autocompletion function.
GDALAlgorithm * | m_owner = nullptr
| Algorithm that may own this argument.

## Friends
struct | test_gdal_algorithm::test_gdal_algorithm

## Detailed Description

Technical class used by GDALAlgorithm when constructing argument declarations.

## Member Function Documentation

## ◆ AddValidationAction()

GDALInConstructionAlgorithmArg & GDALInConstructionAlgorithmArg::AddValidationAction | ( | std::function< bool()> | f | ) |
| inline

Register an action that is executed, once and exactly once, if the argument is explicitly set, at the latest by the ValidateArguments() method.

If the provided function returns false, validation fails. The validation function of a given argument can only check the value of this argument, and cannot assume other arguments have already been set.

## ◆ Get() [1/2]

template<class T >

T & GDALAlgorithmArg::Get | ( |  | ) |
| inline inherited

Return the value of the argument, which is by decreasing order of priority:

- the value set through Set().
- the default value set through SetDefault().
- the initial value of the C++ variable to which this argument is bound to.

Must be called with T consistent of the type of the algorithm:

- bool for GAAT_BOOLEAN
- int for GAAT_INTEGER
- double for GAAT_REAL
- std::string for GAAT_STRING
- GDALArgDatasetValue for GAAT_DATASET
- std::vector<int> for GAAT_INTEGER_LIST
- std::vector<double for GAAT_REAL_LIST
- std::vector<std::string> for GAAT_STRING_LIST
- std::vector<GDALArgDatasetValue> for GAAT_DATASET_LIST

## ◆ Get() [2/2]

template<class T >

const T & GDALAlgorithmArg::Get | ( |  | ) | const
| inline inherited

Return the value of the argument, which is by decreasing order of priority:

- the value set through Set().
- the default value set through SetDefault().
- the initial value of the C++ variable to which this argument is bound to.

Must be called with T consistent of the type of the algorithm:

- bool for GAAT_BOOLEAN
- int for GAAT_INTEGER
- double for GAAT_REAL
- std::string for GAAT_STRING
- GDALArgDatasetValue for GAAT_DATASET
- std::vector<int> for GAAT_INTEGER_LIST
- std::vector<double for GAAT_REAL_LIST
- std::vector<std::string> for GAAT_STRING_LIST
- std::vector<GDALArgDatasetValue> for GAAT_DATASET_LIST

## ◆ Serialize()

bool GDALAlgorithmArg::Serialize | ( | std::string & | serializedArg,
|  | bool | absolutePath = `false`
| ) |  | const
| inherited

Serialize this argument and its value.

May return false if the argument is not explicitly set or if a dataset is passed by value.

## ◆ Set() [1/12]

bool GDALAlgorithmArg::Set | ( | bool | value | ) |
| inherited

Set the value for a GAAT_BOOLEAN argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [2/12]

bool GDALAlgorithmArg::Set | ( | const char * | value | ) |
| inline inherited

Set the value for a GAAT_STRING argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [3/12]

bool GDALAlgorithmArg::Set | ( | const OGRSpatialReference & | value | ) |
| inherited

Set the value for a GAAT_STRING argument (representing a CRS) from a OGRSpatialReference It cannot be called several times for a given argument.

Validation checks and other actions are run. Return true if success.

## ◆ Set() [4/12]

bool GDALAlgorithmArg::Set | ( | const std::string & | value | ) |
| inherited

Set the value for a GAAT_STRING argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [5/12]

bool GDALAlgorithmArg::Set | ( | const std::vector< double > & | value | ) |
| inherited

Set the value for a GAAT_REAL_LIST argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [6/12]

bool GDALAlgorithmArg::Set | ( | const std::vector< int > & | value | ) |
| inherited

Set the value for a GAAT_INTEGER_LIST argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [7/12]

bool GDALAlgorithmArg::Set | ( | const std::vector< std::string > & | value | ) |
| inherited

Set the value for a GAAT_STRING_LIST argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [8/12]

bool GDALAlgorithmArg::Set | ( | GDALDataset * | ds | ) |
| inherited

Set the value for a GAAT_DATASET argument, increasing ds' reference counter if ds is not null.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [9/12]

bool GDALAlgorithmArg::Set | ( | GDALDataType | dt | ) |
| inline inherited

Set the value for a GAAT_STRING argument from a GDALDataType It cannot be called several times for a given argument.

Validation checks and other actions are run. Return true if success.

## ◆ Set() [10/12]

bool GDALAlgorithmArg::Set | ( | int | value | ) |
| inherited

Set the value for a GAAT_INTEGER (or GAAT_REAL) argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [11/12]

bool GDALAlgorithmArg::Set | ( | std::unique_ptr< GDALDataset > | ds | ) |
| inherited

Set the value for a GAAT_DATASET argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ Set() [12/12]

bool GDALAlgorithmArg::Set | ( | std::vector< GDALArgDatasetValue > && | value | ) |
| inherited

Set the value for a GAAT_DATASET_LIST argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ SetAutoCompleteFunction()

GDALInConstructionAlgorithmArg & GDALInConstructionAlgorithmArg::SetAutoCompleteFunction | ( | std::function< std::vector< std::string >(const std::string &)> | f | ) |
| inline

Register a function that will return a list of valid choices for the value of the argument.

This is typically used for autocompletion.

## ◆ SetDatasetName()

bool GDALAlgorithmArg::SetDatasetName | ( | const std::string & | name | ) |
| inherited

Set the value for a GAAT_DATASET argument.

It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ SetFrom() [1/2]

bool GDALAlgorithmArg::SetFrom | ( | const GDALAlgorithmArg & | other | ) |
| inherited

Set the value for another argument.

For GAAT_DATASET, it will reference the dataset pointed by other.m_poDS. It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ SetFrom() [2/2]

bool GDALAlgorithmArg::SetFrom | ( | const GDALArgDatasetValue & | other | ) |
| inherited

Set the value for a GAAT_DATASET argument.

It references the dataset pointed by other.m_poDS. It cannot be called several times for a given argument. Validation checks and other actions are run. Return true if success.

## ◆ SetIsCRSArg()

GDALInConstructionAlgorithmArg & GDALInConstructionAlgorithmArg::SetIsCRSArg | ( | bool | noneAllowed = `false`,
|  | const std::vector< std::string > & | specialValues = `std::vector<std::string>()`
| ) |  |

Register an action to validate that the argument value is a valid CRS definition.

Parameters

  noneAllowed | Set to true to mean that "null" or "none" are allowed to mean to unset CRS.
  specialValues | List of other allowed special values.

The documentation for this class was generated from the following files:

- gdalalgorithm_cpp.h
- gdalalgorithm.cpp