GDAL
GDALAlgorithmArgDecl Class Reference

Argument declaration. More...

#include <gdalalgorithm_cpp.h>

Public Member Functions

 GDALAlgorithmArgDecl (const std::string &longName, char chShortName, const std::string &description, GDALAlgorithmArgType type)
 Constructor.
GDALAlgorithmArgDeclAddAlias (const std::string &alias)
 Declare an alias.
GDALAlgorithmArgDeclAddShortNameAlias (char shortNameAlias)
 Declare a shortname alias.
GDALAlgorithmArgDeclAddHiddenAlias (const std::string &alias)
 Declare an hidden alias (i.e.
GDALAlgorithmArgDeclSetPositional ()
 Declare that the argument is positional.
GDALAlgorithmArgDeclSetRequired ()
 Declare that the argument is required.
GDALAlgorithmArgDeclSetMetaVar (const std::string &metaVar)
 Declare the "meta-var" hint.
GDALAlgorithmArgDeclSetCategory (const std::string &category)
 Declare the argument category: GAAC_COMMON, GAAC_BASE, GAAC_ADVANCED, GAAC_ESOTERIC or a custom category.
template<class T>
GDALAlgorithmArgDeclSetDefault (const T &value)
 Declare a default value for the argument.
GDALAlgorithmArgDeclSetDefault (const char *value)
 Declare a default value for the argument.
GDALAlgorithmArgDeclSetMinCount (int count)
 Declare the minimum number of values for the argument.
GDALAlgorithmArgDeclSetMaxCount (int count)
 Declare the maximum number of values for the argument.
GDALAlgorithmArgDeclSetDisplayHintAboutRepetition (bool displayHint)
 Declare whether in --help message one should display hints about the minimum/maximum number of values.
GDALAlgorithmArgDeclSetPackedValuesAllowed (bool allowed)
 Declares whether, for list type of arguments, several values, comma separated, may be specified.
GDALAlgorithmArgDeclSetRepeatedArgAllowed (bool allowed)
 Declares whether, for list type of arguments, the argument may be repeated.
template<typename T, typename... U, typename std::enable_if<!std::is_same_v< T, std::vector< std::string > & >, bool >::type = true>
GDALAlgorithmArgDeclSetChoices (T &&first, U &&...rest)
 Declares the allowed values (as strings) for the argument.
GDALAlgorithmArgDeclSetChoices (const std::vector< std::string > &choices)
 Declares the allowed values (as strings) for the argument.
GDALAlgorithmArgDeclSetMinValueIncluded (double min)
 Set the minimum (included) value allowed.
GDALAlgorithmArgDeclSetMinValueExcluded (double min)
 Set the minimum (excluded) value allowed.
GDALAlgorithmArgDeclSetMaxValueIncluded (double max)
 Set the maximum (included) value allowed.
GDALAlgorithmArgDeclSetMaxValueExcluded (double max)
 Set the maximum (excluded) value allowed.
GDALAlgorithmArgDeclSetMinCharCount (int count)
 Sets the minimum number of characters (for arguments of type GAAT_STRING and GAAT_STRING_LIST).
template<typename T, typename... U>
GDALAlgorithmArgDeclSetHiddenChoices (T &&first, U &&...rest)
 Declares the, hidden, allowed values (as strings) for the argument.
GDALAlgorithmArgDeclSetHiddenForCLI (bool hiddenForCLI=true)
 Declare that the argument must not be mentioned in CLI usage.
GDALAlgorithmArgDeclSetHiddenForAPI (bool hiddenForAPI=true)
 Declare that the argument is hidden in the context of an API use.
GDALAlgorithmArgDeclSetHidden ()
 Declare that the argument is hidden.
GDALAlgorithmArgDeclSetIsInput (bool isInput=true)
 Indicate whether the value of the argument is read-only during the execution of the algorithm.
GDALAlgorithmArgDeclSetIsOutput (bool isOutput=true)
 Indicate whether (at least part of) the value of the argument is set during the execution of the algorithm.
GDALAlgorithmArgDeclSetMutualExclusionGroup (const std::string &group)
 Set the name of the mutual exclusion group to which this argument belongs to.
GDALAlgorithmArgDeclAddMetadataItem (const std::string &name, const std::vector< std::string > &values)
 Set user-defined metadata item.
GDALAlgorithmArgDeclSetReadFromFileAtSyntaxAllowed ()
 Set that this (string) argument accepts the @filename syntax to mean that the content of the specified file should be used as the value of the argument.
GDALAlgorithmArgDeclSetRemoveSQLCommentsEnabled ()
 Sets that SQL comments must be removed from a (string) argument.
GDALAlgorithmArgDeclSetAutoOpenDataset (bool autoOpen)
 Sets whether the dataset should be opened automatically by GDALAlgorithm.
GDALAlgorithmArgDeclSetUserProvided ()
 Declares that this argument has been created on-the-fly from user-provided argument.
const std::string & GetName () const
 Return the (long) name.
const std::string & GetShortName () const
 Return the short name, or empty string if there is none.
const std::vector< std::string > & GetAliases () const
 Return the aliases (potentially none).
const std::vector< char > & GetShortNameAliases () const
 Return the shortname aliases (potentially none).
const std::string & GetDescription () const
 Return the description.
const std::string & GetMetaVar () const
 Return the "meta-var" hint.
const std::string & GetCategory () const
 Return the argument category: GAAC_COMMON, GAAC_BASE, GAAC_ADVANCED, GAAC_ESOTERIC or a custom category.
GDALAlgorithmArgType GetType () const
 Return the type.
const std::vector< std::string > & GetChoices () const
 Return the allowed values (as strings) for the argument.
const std::vector< std::string > & GetHiddenChoices () const
 Return the allowed hidden values (as strings) for the argument.
std::pair< double, bool > GetMinValue () const
 Return the minimum value and whether it is included.
std::pair< double, bool > GetMaxValue () const
 Return the maximum value and whether it is included.
int GetMinCharCount () const
 Return the minimum number of characters (for arguments of type GAAT_STRING and GAAT_STRING_LIST).
bool IsRequired () const
 Return whether the argument is required.
int GetMinCount () const
 Return the minimum number of values for the argument.
int GetMaxCount () const
 Return the maximum number of values for the argument.
bool GetDisplayHintAboutRepetition () const
 Returns whether in --help message one should display hints about the minimum/maximum number of values.
bool GetPackedValuesAllowed () const
 Return whether, for list type of arguments, several values, space separated, may be specified.
bool GetRepeatedArgAllowed () const
 Return whether, for list type of arguments, the argument may be repeated.
bool IsPositional () const
 Return if the argument is a positional one.
bool HasDefaultValue () const
 Return if the argument has a declared default value.
bool IsHidden () const
 Return whether the argument is hidden.
bool IsHiddenForCLI () const
 Return whether the argument must not be mentioned in CLI usage.
bool IsOnlyForCLI () const
 Return whether the argument is only for CLI usage.
bool IsHiddenForAPI () const
 Return whether the argument is hidden for API usage For example "--help".
bool IsInput () const
 Indicate whether the value of the argument is read-only during the execution of the algorithm.
bool IsOutput () const
 Return whether (at least part of) the value of the argument is set during the execution of the algorithm.
const std::string & GetMutualExclusionGroup () const
 Return the name of the mutual exclusion group to which this argument belongs to, or empty string if it does not belong to any exclusion group.
bool IsReadFromFileAtSyntaxAllowed () const
 Return if this (string) argument accepts the @filename syntax to mean that the content of the specified file should be used as the value of the argument.
bool IsRemoveSQLCommentsEnabled () const
 Returns whether SQL comments must be removed from a (string) argument.
bool AutoOpenDataset () const
 Returns whether the dataset should be opened automatically by GDALAlgorithm.
bool IsUserProvided () const
 Returns whether the argument has been user-provided.
const std::map< std::string, std::vector< std::string > > GetMetadata () const
 Get user-defined metadata.
const std::vector< std::string > * GetMetadataItem (const std::string &name) const
 Get user-defined metadata by item name.
template<class T>
const T & GetDefault () const
 Return the default value of the argument.
GDALArgDatasetType GetDatasetType () const
 Get which type of dataset is allowed / generated.
void SetDatasetType (GDALArgDatasetType type)
 Set which type of dataset is allowed / generated.
int GetDatasetInputFlags () const
 Indicates which components among name and dataset are accepted as input, when this argument serves as an input.
int GetDatasetOutputFlags () const
 Indicates which components among name and dataset are modified, when this argument serves as an output.
void SetDatasetInputFlags (int flags)
 Set which components among name and dataset are accepted as input, when this argument serves as an input.
void SetDatasetOutputFlags (int flags)
 Set which components among name and dataset are modified when this argument serves as an output.

Static Public Attributes

static constexpr int UNBOUNDED = std::numeric_limits<int>::max()
 Special value for the SetMaxCount() / GetMaxCount() to indicate unlimited number of values.

Detailed Description

Argument declaration.

It does not hold its value.

Constructor & Destructor Documentation

◆ GDALAlgorithmArgDecl()

GDALAlgorithmArgDecl::GDALAlgorithmArgDecl ( const std::string & longName,
char chShortName,
const std::string & description,
GDALAlgorithmArgType type )

Constructor.

Parameters
longNameLong name. Must be 2 characters at least. Must not start with dash.
chShortName1-letter short name, or NUL character
descriptionDescription.
typeType of the argument.

Member Function Documentation

◆ AddAlias()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::AddAlias ( const std::string & alias)
inline

Declare an alias.

Must be 2 characters at least.

◆ AddHiddenAlias()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::AddHiddenAlias ( const std::string & alias)
inline

Declare an hidden alias (i.e.

not exposed in usage). Must be 2 characters at least.

◆ AutoOpenDataset()

bool GDALAlgorithmArgDecl::AutoOpenDataset ( ) const
inline

Returns whether the dataset should be opened automatically by GDALAlgorithm.

Only applies to GAAT_DATASET and GAAT_DATASET_LIST.

◆ GetChoices()

const std::vector< std::string > & GDALAlgorithmArgDecl::GetChoices ( ) const
inline

Return the allowed values (as strings) for the argument.

Only honored for GAAT_STRING and GAAT_STRING_LIST types.

◆ GetDatasetInputFlags()

int GDALAlgorithmArgDecl::GetDatasetInputFlags ( ) const
inline

Indicates which components among name and dataset are accepted as input, when this argument serves as an input.

If the GADV_NAME bit is set, it indicates a dataset name is accepted as input. If the GADV_OBJECT bit is set, it indicates a dataset object is accepted as input. If both bits are set, the algorithm can accept either a name or a dataset object. Only applies to arguments of type GAAT_DATASET or GAAT_DATASET_LIST.

◆ GetDatasetOutputFlags()

int GDALAlgorithmArgDecl::GetDatasetOutputFlags ( ) const
inline

Indicates which components among name and dataset are modified, when this argument serves as an output.

If the GADV_NAME bit is set, it indicates a dataset name is generated as output (that is the algorithm will generate the name. Rarely used). If the GADV_OBJECT bit is set, it indicates a dataset object is generated as output, and available for use after the algorithm has completed. Only applies to arguments of type GAAT_DATASET or GAAT_DATASET_LIST.

◆ GetDatasetType()

GDALArgDatasetType GDALAlgorithmArgDecl::GetDatasetType ( ) const
inline

Get which type of dataset is allowed / generated.

Binary-or combination of GDAL_OF_RASTER, GDAL_OF_VECTOR and GDAL_OF_MULTIDIM_RASTER, possibly combined with GDAL_OF_UPDATE. Only applies to arguments of type GAAT_DATASET or GAAT_DATASET_LIST.

◆ GetDefault()

template<class T>
const T & GDALAlgorithmArgDecl::GetDefault ( ) const
inline

Return the default value of the argument.

Must be called with T consistent of the type of the algorithm, and only if HasDefaultValue() is true. Valid T types are:

  • 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

◆ GetDisplayHintAboutRepetition()

bool GDALAlgorithmArgDecl::GetDisplayHintAboutRepetition ( ) const
inline

Returns whether in --help message one should display hints about the minimum/maximum number of values.

Defaults to true.

◆ GetHiddenChoices()

const std::vector< std::string > & GDALAlgorithmArgDecl::GetHiddenChoices ( ) const
inline

Return the allowed hidden values (as strings) for the argument.

Only honored for GAAT_STRING and GAAT_STRING_LIST types.

◆ GetMaxCount()

int GDALAlgorithmArgDecl::GetMaxCount ( ) const
inline

Return the maximum number of values for the argument.

Defaults to 1 for scalar types, and UNBOUNDED for list types. Only applies to list type of arguments.

◆ GetMetaVar()

const std::string & GDALAlgorithmArgDecl::GetMetaVar ( ) const
inline

Return the "meta-var" hint.

By default, the meta-var value is the long name of the argument in upper case.

◆ GetMinCount()

int GDALAlgorithmArgDecl::GetMinCount ( ) const
inline

Return the minimum number of values for the argument.

Defaults to 0. Only applies to list type of arguments.

◆ GetPackedValuesAllowed()

bool GDALAlgorithmArgDecl::GetPackedValuesAllowed ( ) const
inline

Return whether, for list type of arguments, several values, space separated, may be specified.

That is "--foo=bar,baz". The default is true.

◆ GetRepeatedArgAllowed()

bool GDALAlgorithmArgDecl::GetRepeatedArgAllowed ( ) const
inline

Return whether, for list type of arguments, the argument may be repeated.

That is "--foo=bar --foo=baz". The default is true.

◆ IsHiddenForCLI()

bool GDALAlgorithmArgDecl::IsHiddenForCLI ( ) const
inline

Return whether the argument must not be mentioned in CLI usage.

For example, "output-value" for "gdal raster info", which is only meant when the algorithm is used from a non-CLI context.

◆ IsInput()

bool GDALAlgorithmArgDecl::IsInput ( ) const
inline

Indicate whether the value of the argument is read-only during the execution of the algorithm.

Default is true.

◆ IsOnlyForCLI()

bool GDALAlgorithmArgDecl::IsOnlyForCLI ( ) const
inline

Return whether the argument is only for CLI usage.

For example "--help" This is an alias for IsHiddenForAPI()

◆ IsOutput()

bool GDALAlgorithmArgDecl::IsOutput ( ) const
inline

Return whether (at least part of) the value of the argument is set during the execution of the algorithm.

For example, "output-value" for "gdal raster info" Default is false. An argument may return both IsInput() and IsOutput() as true. For example the "gdal raster convert" algorithm consumes the dataset name of its "output" argument, and sets the dataset object during its execution.

◆ IsRequired()

bool GDALAlgorithmArgDecl::IsRequired ( ) const
inline

Return whether the argument is required.

Defaults to false.

◆ SetAutoOpenDataset()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetAutoOpenDataset ( bool autoOpen)
inline

Sets whether the dataset should be opened automatically by GDALAlgorithm.

Only applies to GAAT_DATASET and GAAT_DATASET_LIST.

◆ SetChoices() [1/2]

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetChoices ( const std::vector< std::string > & choices)
inline

Declares the allowed values (as strings) for the argument.

Only honored for GAAT_STRING and GAAT_STRING_LIST types.

◆ SetChoices() [2/2]

template<typename T, typename... U, typename std::enable_if<!std::is_same_v< T, std::vector< std::string > & >, bool >::type = true>
GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetChoices ( T && first,
U &&... rest )
inline

Declares the allowed values (as strings) for the argument.

Only honored for GAAT_STRING and GAAT_STRING_LIST types.

◆ SetDatasetInputFlags()

void GDALAlgorithmArgDecl::SetDatasetInputFlags ( int flags)
inline

Set which components among name and dataset are accepted as input, when this argument serves as an input.

Only applies to arguments of type GAAT_DATASET or GAAT_DATASET_LIST.

◆ SetDatasetOutputFlags()

void GDALAlgorithmArgDecl::SetDatasetOutputFlags ( int flags)
inline

Set which components among name and dataset are modified when this argument serves as an output.

Only applies to arguments of type GAAT_DATASET or GAAT_DATASET_LIST.

◆ SetDatasetType()

void GDALAlgorithmArgDecl::SetDatasetType ( GDALArgDatasetType type)
inline

Set which type of dataset is allowed / generated.

Binary-or combination of GDAL_OF_RASTER, GDAL_OF_VECTOR and GDAL_OF_MULTIDIM_RASTER. Only applies to arguments of type GAAT_DATASET or GAAT_DATASET_LIST.

◆ SetDisplayHintAboutRepetition()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetDisplayHintAboutRepetition ( bool displayHint)
inline

Declare whether in --help message one should display hints about the minimum/maximum number of values.

Defaults to true.

◆ SetHidden()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetHidden ( )
inline

Declare that the argument is hidden.

Default is no. This is equivalent to calling SetHiddenForCLI() and SetHiddenForAPI()

◆ SetHiddenChoices()

template<typename T, typename... U>
GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetHiddenChoices ( T && first,
U &&... rest )
inline

Declares the, hidden, allowed values (as strings) for the argument.

Only honored for GAAT_STRING and GAAT_STRING_LIST types.

◆ SetHiddenForAPI()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetHiddenForAPI ( bool hiddenForAPI = true)
inline

Declare that the argument is hidden in the context of an API use.

Said otherwise, if it is only for CLI usage. For example "--help"

◆ SetHiddenForCLI()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetHiddenForCLI ( bool hiddenForCLI = true)
inline

Declare that the argument must not be mentioned in CLI usage.

For example, "output-value" for "gdal raster info", which is only meant when the algorithm is used from a non-CLI context.

◆ SetIsInput()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetIsInput ( bool isInput = true)
inline

Indicate whether the value of the argument is read-only during the execution of the algorithm.

Default is true.

◆ SetIsOutput()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetIsOutput ( bool isOutput = true)
inline

Indicate whether (at least part of) the value of the argument is set during the execution of the algorithm.

For example, "output-value" for "gdal raster info" Default is false. An argument may return both IsInput() and IsOutput() as true. For example the "gdal raster convert" algorithm consumes the dataset name of its "output" argument, and sets the dataset object during its execution.

◆ SetMaxCount()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetMaxCount ( int count)

Declare the maximum number of values for the argument.

Defaults to 1 for scalar types, and UNBOUNDED for list types. Only applies to list type of arguments.

◆ SetMetaVar()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetMetaVar ( const std::string & metaVar)
inline

Declare the "meta-var" hint.

By default, the meta-var value is the long name of the argument in upper case.

◆ SetMinCount()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetMinCount ( int count)

Declare the minimum number of values for the argument.

Defaults to 0. Only applies to list type of arguments. Setting it to non-zero does not make the argument required. It just sets the minimum number of values when it is specified. To also make it required, use SetRequired().

◆ SetMinValueExcluded()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetMinValueExcluded ( double min)
inline

Set the minimum (excluded) value allowed.

Only taken into account on GAAT_INTEGER, GAAT_INTEGER_LIST, GAAT_REAL and GAAT_REAL_LIST arguments.

◆ SetMinValueIncluded()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetMinValueIncluded ( double min)
inline

Set the minimum (included) value allowed.

Only taken into account on GAAT_INTEGER, GAAT_INTEGER_LIST, GAAT_REAL and GAAT_REAL_LIST arguments.

◆ SetMutualExclusionGroup()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetMutualExclusionGroup ( const std::string & group)
inline

Set the name of the mutual exclusion group to which this argument belongs to.

At most one argument in a group can be specified.

◆ SetPackedValuesAllowed()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetPackedValuesAllowed ( bool allowed)
inline

Declares whether, for list type of arguments, several values, comma separated, may be specified.

That is "--foo=bar,baz". The default is true.

◆ SetPositional()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetPositional ( )
inline

Declare that the argument is positional.

Typically input / output files

◆ SetRepeatedArgAllowed()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetRepeatedArgAllowed ( bool allowed)
inline

Declares whether, for list type of arguments, the argument may be repeated.

That is "--foo=bar --foo=baz". The default is true.

◆ SetRequired()

GDALAlgorithmArgDecl & GDALAlgorithmArgDecl::SetRequired ( )
inline

Declare that the argument is required.

Default is no


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