GDAL
gdalalgorithm_cpp.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: GDALAlgorithm C++ API
5 * Author: Even Rouault <even dot rouault at spatialys.com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDAL_ALGORITHM_CPP_INCLUDED
14#define GDAL_ALGORITHM_CPP_INCLUDED
15
16#include "gdalalgorithm_c.h"
17
18/************************************************************************/
19/************************************************************************/
20/* GDAL Algorithm C++ API */
21/************************************************************************/
22/************************************************************************/
23
24// This header requires C++17
25// _MSC_VER >= 1920 : Visual Studio >= 2019
26#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && \
27 (defined(DOXYGEN_SKIP) || __cplusplus >= 201703L || _MSC_VER >= 1920)
28
29#include "cpl_error.h"
30#include "ogr_feature.h"
31#include <limits>
32#include <functional>
33#include <map>
34#include <memory>
35#include <string>
36#include <string_view>
37#include <type_traits>
38#include <utility>
39#include <variant>
40#include <vector>
41
42class GDALDataset;
44
46constexpr const char *GAAC_COMMON = "Common";
47
49constexpr const char *GAAC_BASE = "Base";
50
52constexpr const char *GAAC_ADVANCED = "Advanced";
53
55constexpr const char *GAAC_ESOTERIC = "Esoteric";
56
59constexpr const char *GAAMDI_REQUIRED_CAPABILITIES = "required_capabilities";
60
62constexpr const char *GAAMDI_VRT_COMPATIBLE = "vrt_compatible";
63
65constexpr const char *GAAMDI_ALLOWED_FORMATS = "allowed_formats";
66
68constexpr const char *GAAMDI_EXCLUDED_FORMATS = "excluded_formats";
69
71constexpr const char *GAAMDI_EXTRA_FORMATS = "extra_formats";
72
74constexpr const char *GDAL_ARG_NAME_INPUT = "input";
75
77constexpr const char *GDAL_ARG_NAME_INPUT_CRS = "input-crs";
78
80constexpr const char *GDAL_ARG_NAME_INPUT_FORMAT = "input-format";
81
83constexpr const char *GDAL_ARG_NAME_INPUT_LAYER = "input-layer";
84
86constexpr const char *GDAL_ARG_NAME_OPEN_OPTION = "open-option";
87
89constexpr const char *GDAL_ARG_NAME_OUTPUT = "output";
90
92constexpr const char *GDAL_ARG_NAME_OUTPUT_STRING = "output-string";
93
95constexpr const char *GDAL_ARG_NAME_STDOUT = "stdout";
96
98constexpr const char *GDAL_ARG_NAME_OUTPUT_CRS = "output-crs";
99
101constexpr const char *GDAL_ARG_NAME_OUTPUT_FORMAT = "output-format";
102
104constexpr const char *GDAL_ARG_NAME_OUTPUT_LAYER = "output-layer";
105
107constexpr const char *GDAL_ARG_NAME_CREATION_OPTION = "creation-option";
108
110constexpr const char *GDAL_ARG_NAME_LAYER_CREATION_OPTION =
111 "layer-creation-option";
112
114constexpr const char *GDAL_ARG_NAME_UPDATE = "update";
115
117constexpr const char *GDAL_ARG_NAME_OVERWRITE = "overwrite";
118
120constexpr const char *GDAL_ARG_NAME_OVERWRITE_LAYER = "overwrite-layer";
121
123constexpr const char *GDAL_ARG_NAME_APPEND = "append";
124
126constexpr const char *GDAL_ARG_NAME_READ_ONLY = "read-only";
127
129constexpr const char *GDAL_ARG_NAME_NUM_THREADS = "num-threads";
130
132constexpr const char *GDAL_ARG_NAME_NUM_THREADS_INT_HIDDEN =
133 "num-threads-int-hidden";
134
136constexpr const char *GDAL_ARG_NAME_QUIET = "quiet";
137
141constexpr const char *GDAL_ALG_DCAP_RASTER_OR_MULTIDIM_RASTER =
142 "raster-or-multidim-raster";
143
147constexpr const char *GDAL_DATASET_PIPELINE_PLACEHOLDER_VALUE = "_PIPE_";
148
149/************************************************************************/
150/* GDALArgDatasetValue */
151/************************************************************************/
152
154std::string CPL_DLL GDALAlgorithmArgDatasetTypeName(GDALArgDatasetType);
155
156class GDALAlgorithmArg;
157
162class CPL_DLL GDALArgDatasetValue final
163{
164 public:
167
169 explicit GDALArgDatasetValue(const std::string &name)
170 : m_name(name), m_nameSet(true)
171 {
172 }
173
175 explicit GDALArgDatasetValue(GDALDataset *poDS);
176
179
183
186 bool Close();
187
189 GDALArgDatasetValue &operator=(GDALArgDatasetValue &&other);
190
195 GDALDataset *GetDatasetIncreaseRefCount();
196
202 {
203 return m_poDS;
204 }
205
211 {
212 return m_poDS;
213 }
214
219 {
220 GDALDataset *ret = m_poDS;
221 m_poDS = nullptr;
222 return ret;
223 }
224
229 {
230 Close();
231 m_poDS = other.BorrowDataset();
232 m_name = other.m_name;
233 }
234
236 const std::string &GetName() const
237 {
238 return m_name;
239 }
240
242 bool IsNameSet() const
243 {
244 return m_nameSet;
245 }
246
248 void Set(const std::string &name);
249
252 void Set(std::unique_ptr<GDALDataset> poDS);
253
255 void Set(GDALDataset *poDS);
256
260 void SetFrom(const GDALArgDatasetValue &other);
261
264 {
265 m_openedByAlgorithm = true;
266 }
267
270 {
271 return m_openedByAlgorithm;
272 }
273
274 protected:
275 friend class GDALAlgorithm;
276
279 {
280 CPLAssert(!m_ownerArg);
281 m_ownerArg = arg;
282 }
283
284 private:
286 GDALAlgorithmArg *m_ownerArg = nullptr;
287
289 GDALDataset *m_poDS = nullptr;
290
292 std::string m_name{};
293
295 bool m_nameSet = false;
296
298 bool m_openedByAlgorithm = false;
299
301 GDALArgDatasetValue &operator=(const GDALArgDatasetValue &) = delete;
302};
303
304/************************************************************************/
305/* GDALAlgorithmArgDecl */
306/************************************************************************/
307
312class CPL_DLL GDALAlgorithmArgDecl final
313{
314 public:
317 static constexpr int UNBOUNDED = std::numeric_limits<int>::max();
318
327 GDALAlgorithmArgDecl(const std::string &longName, char chShortName,
328 const std::string &description,
329 GDALAlgorithmArgType type);
330
332 GDALAlgorithmArgDecl &AddAlias(const std::string &alias)
333 {
334 m_aliases.push_back(alias);
335 return *this;
336 }
337
340 {
341 m_shortNameAliases.push_back(shortNameAlias);
342 return *this;
343 }
344
347 GDALAlgorithmArgDecl &AddHiddenAlias(const std::string &alias)
348 {
349 m_hiddenAliases.push_back(alias);
350 return *this;
351 }
352
356 {
357 m_positional = true;
358 return *this;
359 }
360
364 {
365 m_required = true;
366 return *this;
367 }
368
373 GDALAlgorithmArgDecl &SetMetaVar(const std::string &metaVar)
374 {
375 m_metaVar = metaVar;
376 return *this;
377 }
378
382 GDALAlgorithmArgDecl &SetCategory(const std::string &category)
383 {
384 m_category = category;
385 return *this;
386 }
387
390 template <class T> GDALAlgorithmArgDecl &SetDefault(const T &value)
391 {
392 m_hasDefaultValue = true;
393 try
394 {
395 switch (m_type)
396 {
397 case GAAT_BOOLEAN:
398 {
399 if constexpr (std::is_same_v<T, bool>)
400 {
401 m_defaultValue = value;
402 return *this;
403 }
404 break;
405 }
406
407 case GAAT_STRING:
408 {
409 if constexpr (std::is_same_v<T, std::string>)
410 {
411 m_defaultValue = value;
412 return *this;
413 }
414 break;
415 }
416
417 case GAAT_INTEGER:
418 {
419 if constexpr (std::is_same_v<T, int>)
420 {
421 m_defaultValue = value;
422 return *this;
423 }
424 break;
425 }
426
427 case GAAT_REAL:
428 {
429 if constexpr (std::is_assignable_v<double &, T>)
430 {
431 m_defaultValue = static_cast<double>(value);
432 return *this;
433 }
434 break;
435 }
436
437 case GAAT_STRING_LIST:
438 {
439 if constexpr (std::is_same_v<T, std::string>)
440 {
441 m_defaultValue = std::vector<std::string>{value};
442 return *this;
443 }
444 else if constexpr (std::is_same_v<T,
445 std::vector<std::string>>)
446 {
447 m_defaultValue = value;
448 return *this;
449 }
450 break;
451 }
452
453 case GAAT_INTEGER_LIST:
454 {
455 if constexpr (std::is_same_v<T, int>)
456 {
457 m_defaultValue = std::vector<int>{value};
458 return *this;
459 }
460 else if constexpr (std::is_same_v<T, std::vector<int>>)
461 {
462 m_defaultValue = value;
463 return *this;
464 }
465 break;
466 }
467
468 case GAAT_REAL_LIST:
469 {
470 if constexpr (std::is_assignable_v<double &, T>)
471 {
472 m_defaultValue =
473 std::vector<double>{static_cast<double>(value)};
474 return *this;
475 }
476 else if constexpr (std::is_same_v<T, std::vector<double>>)
477 {
478 m_defaultValue = value;
479 return *this;
480 }
481 break;
482 }
483
484 case GAAT_DATASET:
485 case GAAT_DATASET_LIST:
486 break;
487 }
488 }
489 catch (const std::bad_variant_access &)
490 {
491 // should not happen
492 // fallthrough
493 }
494 CPLError(CE_Failure, CPLE_AppDefined,
495 "Argument %s: SetDefault(): unexpected type for value",
496 GetName().c_str());
497 return *this;
498 }
499
503 {
504 return SetDefault(std::string(value));
505 }
506
513 GDALAlgorithmArgDecl &SetMinCount(int count);
514
519 GDALAlgorithmArgDecl &SetMaxCount(int count);
520
525 {
526 m_displayHintAboutRepetition = displayHint;
527 return *this;
528 }
529
535 {
536 m_packedValuesAllowed = allowed;
537 return *this;
538 }
539
545 {
546 m_repeatedArgAllowed = allowed;
547 return *this;
548 }
549
555 {
556 m_duplicateValuesAllowed = allowed;
557 return *this;
558 }
559
561 GDALAlgorithmArgDecl &SetChoices()
562 {
563 return *this;
564 }
565
567
571 template <
572 typename T, typename... U,
573 typename std::enable_if<!std::is_same_v<T, std::vector<std::string> &>,
574 bool>::type = true>
575 GDALAlgorithmArgDecl &SetChoices(T &&first, U &&...rest)
576 {
577 m_choices.push_back(std::forward<T>(first));
578 SetChoices(std::forward<U>(rest)...);
579 return *this;
580 }
581
585 GDALAlgorithmArgDecl &SetChoices(const std::vector<std::string> &choices)
586 {
587 m_choices = choices;
588 return *this;
589 }
590
597 {
598 m_minVal = min;
599 m_minValIsIncluded = true;
600 return *this;
601 }
602
609 {
610 m_minVal = min;
611 m_minValIsIncluded = false;
612 return *this;
613 }
614
617 {
618 m_maxVal = max;
619 m_maxValIsIncluded = true;
620 return *this;
621 }
622
625 {
626 m_maxVal = max;
627 m_maxValIsIncluded = false;
628 return *this;
629 }
630
635 {
636 m_minCharCount = count;
637 return *this;
638 }
639
644 {
645 m_maxCharCount = count;
646 return *this;
647 }
648
650 GDALAlgorithmArgDecl &SetHiddenChoices()
651 {
652 return *this;
653 }
654
656
660 template <typename T, typename... U>
661 GDALAlgorithmArgDecl &SetHiddenChoices(T &&first, U &&...rest)
662 {
663 m_hiddenChoices.push_back(std::forward<T>(first));
664 SetHiddenChoices(std::forward<U>(rest)...);
665 return *this;
666 }
667
672 GDALAlgorithmArgDecl &SetHiddenForCLI(bool hiddenForCLI = true)
673 {
674 m_hiddenForCLI = hiddenForCLI;
675 return *this;
676 }
677
681 GDALAlgorithmArgDecl &SetHiddenForAPI(bool hiddenForAPI = true)
682 {
683 m_hiddenForAPI = hiddenForAPI;
684 return *this;
685 }
686
691 {
692 m_hiddenForCLI = true;
693 m_hiddenForAPI = true;
694 return *this;
695 }
696
700 GDALAlgorithmArgDecl &SetIsInput(bool isInput = true)
701 {
702 m_isInput = isInput;
703 return *this;
704 }
705
715 GDALAlgorithmArgDecl &SetIsOutput(bool isOutput = true)
716 {
717 m_isOutput = isOutput;
718 return *this;
719 }
720
725 {
726 m_mutualExclusionGroup = group;
727 return *this;
728 }
729
737 {
738 m_mutualDependencyGroup = group;
739 return *this;
740 }
741
743 inline const std::string &GetMutualDependencyGroup() const
744 {
745 return m_mutualDependencyGroup;
746 }
747
753 GDALAlgorithmArgDecl &AddDirectDependency(const std::string &otherArgName)
754 {
755 m_directDependencies.push_back(otherArgName);
756 return *this;
757 }
758
762 AddMetadataItem(const std::string &name,
763 const std::vector<std::string> &values)
764 {
765 m_metadata[name] = values;
766 return *this;
767 }
768
774 {
775 m_readFromFileAtSyntaxAllowed = true;
776 return *this;
777 }
778
782 {
783 m_removeSQLComments = true;
784 return *this;
785 }
786
791 {
792 m_autoOpenDataset = autoOpen;
793 return *this;
794 }
795
800 {
801 m_userProvided = true;
802 return *this;
803 }
804
806 inline const std::string &GetName() const
807 {
808 return m_longName;
809 }
810
812 inline const std::string &GetShortName() const
813 {
814 return m_shortName;
815 }
816
818 inline const std::vector<std::string> &GetAliases() const
819 {
820 return m_aliases;
821 }
822
824 inline const std::vector<char> &GetShortNameAliases() const
825 {
826 return m_shortNameAliases;
827 }
828
830 inline const std::string &GetDescription() const
831 {
832 return m_description;
833 }
834
839 inline const std::string &GetMetaVar() const
840 {
841 return m_metaVar;
842 }
843
847 inline const std::string &GetCategory() const
848 {
849 return m_category;
850 }
851
853 inline GDALAlgorithmArgType GetType() const
854 {
855 return m_type;
856 }
857
861 inline const std::vector<std::string> &GetChoices() const
862 {
863 return m_choices;
864 }
865
869 inline const std::vector<std::string> &GetHiddenChoices() const
870 {
871 return m_hiddenChoices;
872 }
873
875 inline std::pair<double, bool> GetMinValue() const
876 {
877 return {m_minVal, m_minValIsIncluded};
878 }
879
881 inline std::pair<double, bool> GetMaxValue() const
882 {
883 return {m_maxVal, m_maxValIsIncluded};
884 }
885
889 inline int GetMinCharCount() const
890 {
891 return m_minCharCount;
892 }
893
897 inline int GetMaxCharCount() const
898 {
899 return m_maxCharCount;
900 }
901
904 inline bool IsRequired() const
905 {
906 return m_required;
907 }
908
912 inline int GetMinCount() const
913 {
914 return m_minCount;
915 }
916
921 inline int GetMaxCount() const
922 {
923 return m_maxCount;
924 }
925
930 {
931 return m_displayHintAboutRepetition;
932 }
933
938 inline bool GetPackedValuesAllowed() const
939 {
940 return m_packedValuesAllowed;
941 }
942
947 inline bool GetRepeatedArgAllowed() const
948 {
949 return m_repeatedArgAllowed;
950 }
951
956 inline bool GetDuplicateValuesAllowed() const
957 {
958 return m_duplicateValuesAllowed;
959 }
960
962 inline bool IsPositional() const
963 {
964 return m_positional;
965 }
966
968 inline bool HasDefaultValue() const
969 {
970 return m_hasDefaultValue;
971 }
972
975 inline bool IsHidden() const
976 {
977 return m_hiddenForCLI && m_hiddenForAPI;
978 }
979
984 inline bool IsHiddenForCLI() const
985 {
986 return m_hiddenForCLI;
987 }
988
993 inline bool IsOnlyForCLI() const
994 CPL_WARN_DEPRECATED("Use IsHiddenForAPI() instead")
995 {
996 return m_hiddenForAPI;
997 }
998
1001 inline bool IsHiddenForAPI() const
1002 {
1003 return m_hiddenForAPI;
1004 }
1005
1009 inline bool IsInput() const
1010 {
1011 return m_isInput;
1012 }
1013
1023 inline bool IsOutput() const
1024 {
1025 return m_isOutput;
1026 }
1027
1032 inline const std::string &GetMutualExclusionGroup() const
1033 {
1034 return m_mutualExclusionGroup;
1035 }
1036
1047 inline const std::vector<std::string> &GetDirectDependencies() const
1048 {
1049 return m_directDependencies;
1050 }
1051
1057 {
1058 return m_readFromFileAtSyntaxAllowed;
1059 }
1060
1064 {
1065 return m_removeSQLComments;
1066 }
1067
1071 bool AutoOpenDataset() const
1072 {
1073 return m_autoOpenDataset;
1074 }
1075
1078 bool IsUserProvided() const
1079 {
1080 return m_userProvided;
1081 }
1082
1084 inline const std::map<std::string, std::vector<std::string>>
1086 {
1087 return m_metadata;
1088 }
1089
1091 inline const std::vector<std::string> *
1092 GetMetadataItem(const std::string &name) const
1093 {
1094 const auto iter = m_metadata.find(name);
1095 return iter == m_metadata.end() ? nullptr : &(iter->second);
1096 }
1097
1112 template <class T> inline const T &GetDefault() const
1113 {
1114 return std::get<T>(m_defaultValue);
1115 }
1116
1122 GDALArgDatasetType GetDatasetType() const
1123 {
1124 return m_datasetType;
1125 }
1126
1132 void SetDatasetType(GDALArgDatasetType type)
1133 {
1134 m_datasetType = type;
1135 }
1136
1149 {
1150 return m_datasetInputFlags;
1151 }
1152
1164 {
1165 return m_datasetOutputFlags;
1166 }
1167
1172 void SetDatasetInputFlags(int flags)
1173 {
1174 m_datasetInputFlags = flags;
1175 }
1176
1182 {
1183 m_datasetOutputFlags = flags;
1184 }
1185
1190 void SetAvailableInPipelineStep(bool available)
1191 {
1192 m_availableInPipelineStep = available;
1193 }
1194
1200 {
1201 return m_availableInPipelineStep;
1202 }
1203
1204 private:
1205 const std::string m_longName;
1206 const std::string m_shortName;
1207 const std::string m_description;
1208 const GDALAlgorithmArgType m_type;
1209 std::string m_category = GAAC_BASE;
1210 std::string m_metaVar{};
1211 std::string m_mutualExclusionGroup{};
1212 std::string m_mutualDependencyGroup{};
1213 int m_minCount = 0;
1214 int m_maxCount = 0;
1215 bool m_required = false;
1216 bool m_positional = false;
1217 bool m_hasDefaultValue = false;
1218 bool m_hiddenForCLI = false;
1219 bool m_hiddenForAPI = false;
1220 bool m_isInput = true;
1221 bool m_isOutput = false;
1222 bool m_packedValuesAllowed = true;
1223 bool m_repeatedArgAllowed = true;
1224 bool m_displayHintAboutRepetition = true;
1225 bool m_readFromFileAtSyntaxAllowed = false;
1226 bool m_removeSQLComments = false;
1227 bool m_autoOpenDataset = true;
1228 bool m_userProvided = false;
1229 bool m_duplicateValuesAllowed = true;
1230 bool m_availableInPipelineStep = true;
1231 std::map<std::string, std::vector<std::string>> m_metadata{};
1232 std::vector<std::string> m_aliases{};
1233 std::vector<std::string> m_hiddenAliases{};
1234 std::vector<std::string> m_directDependencies{};
1235 std::vector<char> m_shortNameAliases{};
1236 std::vector<std::string> m_choices{};
1237 std::vector<std::string> m_hiddenChoices{};
1238 std::variant<bool, std::string, int, double, std::vector<std::string>,
1239 std::vector<int>, std::vector<double>>
1240 m_defaultValue{};
1241 double m_minVal = std::numeric_limits<double>::quiet_NaN();
1242 double m_maxVal = std::numeric_limits<double>::quiet_NaN();
1243 bool m_minValIsIncluded = false;
1244 bool m_maxValIsIncluded = false;
1245 int m_minCharCount = 0;
1246 int m_maxCharCount = std::numeric_limits<int>::max();
1247 GDALArgDatasetType m_datasetType =
1249
1253 int m_datasetInputFlags = GADV_NAME | GADV_OBJECT;
1254
1258 int m_datasetOutputFlags = GADV_OBJECT;
1259};
1260
1261/************************************************************************/
1262/* GDALAlgorithmArg */
1263/************************************************************************/
1264
1265class GDALAlgorithm;
1266
1269class CPL_DLL GDALAlgorithmArg /* non-final */
1270{
1271 public:
1273 template <class T>
1275 : m_decl(decl), m_value(pValue)
1276 {
1277 if constexpr (!std::is_same_v<T, GDALArgDatasetValue> &&
1278 !std::is_same_v<T, std::vector<GDALArgDatasetValue>>)
1279 {
1280 if (decl.HasDefaultValue())
1281 {
1282 try
1283 {
1284 *std::get<T *>(m_value) = decl.GetDefault<T>();
1285 }
1286 catch (const std::bad_variant_access &e)
1287 {
1288 // I don't think that can happen, but Coverity Scan thinks
1289 // so
1290 CPLError(CE_Failure, CPLE_AppDefined,
1291 "*std::get<T *>(m_value) = decl.GetDefault<T>() "
1292 "failed: %s",
1293 e.what());
1294 }
1295 }
1296 }
1297 }
1298
1301
1304 {
1305 return m_decl;
1306 }
1307
1309 inline const std::string &GetName() const
1310 {
1311 return m_decl.GetName();
1312 }
1313
1315 inline const std::string &GetShortName() const
1316 {
1317 return m_decl.GetShortName();
1318 }
1319
1321 inline const std::vector<std::string> &GetAliases() const
1322 {
1323 return m_decl.GetAliases();
1324 }
1325
1327 inline const std::vector<char> &GetShortNameAliases() const
1328 {
1329 return m_decl.GetShortNameAliases();
1330 }
1331
1333 inline const std::string &GetDescription() const
1334 {
1335 return m_decl.GetDescription();
1336 }
1337
1339 inline const std::string &GetMetaVar() const
1340 {
1341 return m_decl.GetMetaVar();
1342 }
1343
1345 inline GDALAlgorithmArgType GetType() const
1346 {
1347 return m_decl.GetType();
1348 }
1349
1351 inline const std::string &GetCategory() const
1352 {
1353 return m_decl.GetCategory();
1354 }
1355
1357 inline bool IsRequired() const
1358 {
1359 return m_decl.IsRequired();
1360 }
1361
1363 inline int GetMinCount() const
1364 {
1365 return m_decl.GetMinCount();
1366 }
1367
1369 inline int GetMaxCount() const
1370 {
1371 return m_decl.GetMaxCount();
1372 }
1373
1376 {
1377 return m_decl.GetDisplayHintAboutRepetition();
1378 }
1379
1381 inline bool GetPackedValuesAllowed() const
1382 {
1383 return m_decl.GetPackedValuesAllowed();
1384 }
1385
1387 inline bool GetRepeatedArgAllowed() const
1388 {
1389 return m_decl.GetRepeatedArgAllowed();
1390 }
1391
1393 inline bool GetDuplicateValuesAllowed() const
1394 {
1395 return m_decl.GetDuplicateValuesAllowed();
1396 }
1397
1399 inline bool IsPositional() const
1400 {
1401 return m_decl.IsPositional();
1402 }
1403
1405 inline const std::vector<std::string> &GetChoices() const
1406 {
1407 return m_decl.GetChoices();
1408 }
1409
1411 inline const std::vector<std::string> &GetHiddenChoices() const
1412 {
1413 return m_decl.GetHiddenChoices();
1414 }
1415
1419 inline std::vector<std::string>
1420 GetAutoCompleteChoices(const std::string &currentValue) const
1421 {
1422 if (m_autoCompleteFunction)
1423 return m_autoCompleteFunction(currentValue);
1424 return {};
1425 }
1426
1428 inline std::pair<double, bool> GetMinValue() const
1429 {
1430 return m_decl.GetMinValue();
1431 }
1432
1434 inline std::pair<double, bool> GetMaxValue() const
1435 {
1436 return m_decl.GetMaxValue();
1437 }
1438
1440 inline int GetMinCharCount() const
1441 {
1442 return m_decl.GetMinCharCount();
1443 }
1444
1446 inline int GetMaxCharCount() const
1447 {
1448 return m_decl.GetMaxCharCount();
1449 }
1450
1452 inline bool IsExplicitlySet() const
1453 {
1454 return m_explicitlySet;
1455 }
1456
1458 inline bool HasDefaultValue() const
1459 {
1460 return m_decl.HasDefaultValue();
1461 }
1462
1464 inline bool IsHidden() const
1465 {
1466 return m_decl.IsHidden();
1467 }
1468
1470 inline bool IsHiddenForCLI() const
1471 {
1472 return m_decl.IsHiddenForCLI();
1473 }
1474
1476 inline bool IsOnlyForCLI() const
1477 CPL_WARN_DEPRECATED("Use IsHiddenForAPI() instead")
1478 {
1479 return m_decl.IsHiddenForAPI();
1480 }
1481
1483 inline bool IsHiddenForAPI() const
1484 {
1485 return m_decl.IsHiddenForAPI();
1486 }
1487
1489 inline bool IsInput() const
1490 {
1491 return m_decl.IsInput();
1492 }
1493
1495 inline bool IsOutput() const
1496 {
1497 return m_decl.IsOutput();
1498 }
1499
1502 {
1503 return m_decl.IsReadFromFileAtSyntaxAllowed();
1504 }
1505
1507 inline bool IsRemoveSQLCommentsEnabled() const
1508 {
1509 return m_decl.IsRemoveSQLCommentsEnabled();
1510 }
1511
1513 inline const std::string &GetMutualExclusionGroup() const
1514 {
1515 return m_decl.GetMutualExclusionGroup();
1516 }
1517
1519 inline const std::string &GetMutualDependencyGroup() const
1520 {
1521 return m_decl.GetMutualDependencyGroup();
1522 }
1523
1525 inline const std::vector<std::string> &GetDirectDependencies() const
1526 {
1527 return m_decl.GetDirectDependencies();
1528 }
1529
1531 inline const std::map<std::string, std::vector<std::string>>
1533 {
1534 return m_decl.GetMetadata();
1535 }
1536
1538 inline const std::vector<std::string> *
1539 GetMetadataItem(const std::string &name) const
1540 {
1541 return m_decl.GetMetadataItem(name);
1542 }
1543
1545 template <class T> inline const T &GetDefault() const
1546 {
1547 return m_decl.GetDefault<T>();
1548 }
1549
1551 inline bool AutoOpenDataset() const
1552 {
1553 return m_decl.AutoOpenDataset();
1554 }
1555
1557 inline bool IsUserProvided() const
1558 {
1559 return m_decl.IsUserProvided();
1560 }
1561
1563 inline GDALArgDatasetType GetDatasetType() const
1564 {
1565 return m_decl.GetDatasetType();
1566 }
1567
1569 inline int GetDatasetInputFlags() const
1570 {
1571 return m_decl.GetDatasetInputFlags();
1572 }
1573
1575 inline int GetDatasetOutputFlags() const
1576 {
1577 return m_decl.GetDatasetOutputFlags();
1578 }
1579
1581 inline bool IsAvailableInPipelineStep() const
1582 {
1583 return m_decl.IsAvailableInPipelineStep();
1584 }
1585
1602 template <class T> inline T &Get()
1603 {
1604 return *(std::get<T *>(m_value));
1605 }
1606
1623 template <class T> inline const T &Get() const
1624 {
1625 return *(std::get<T *>(m_value));
1626 }
1627
1633 bool Set(bool value);
1634
1640 bool Set(const std::string &value);
1641
1647 bool Set(const char *value)
1648 {
1649 return Set(std::string(value ? value : ""));
1650 }
1651
1658 {
1659 return Set(GDALGetDataTypeName(dt));
1660 }
1661
1668 bool Set(const OGRSpatialReference &);
1669
1675 bool Set(int value);
1676
1678 bool Set(double value);
1679
1686 bool Set(GDALDataset *ds);
1687
1693 bool Set(std::unique_ptr<GDALDataset> ds);
1694
1700 bool SetDatasetName(const std::string &name);
1701
1708 bool SetFrom(const GDALArgDatasetValue &other);
1709
1715 bool Set(const std::vector<std::string> &value);
1716
1722 bool Set(const std::vector<int> &value);
1723
1729 bool Set(const std::vector<double> &value);
1730
1736 bool Set(std::vector<GDALArgDatasetValue> &&value);
1737
1739 inline GDALAlgorithmArg &operator=(bool value)
1740 {
1741 Set(value);
1742 return *this;
1743 }
1744
1746 inline GDALAlgorithmArg &operator=(int value)
1747 {
1748 Set(value);
1749 return *this;
1750 }
1751
1753 inline GDALAlgorithmArg &operator=(double value)
1754 {
1755 Set(value);
1756 return *this;
1757 }
1758
1760 inline GDALAlgorithmArg &operator=(const std::string &value)
1761 {
1762 Set(value);
1763 return *this;
1764 }
1765
1767 inline GDALAlgorithmArg &operator=(const char *value)
1768 {
1769 Set(value);
1770 return *this;
1771 }
1772
1775 {
1776 Set(value);
1777 return *this;
1778 }
1779
1782 {
1783 Set(value);
1784 return *this;
1785 }
1786
1788 inline GDALAlgorithmArg &operator=(const std::vector<int> &value)
1789 {
1790 Set(value);
1791 return *this;
1792 }
1793
1795 inline GDALAlgorithmArg &operator=(const std::vector<double> &value)
1796 {
1797 Set(value);
1798 return *this;
1799 }
1800
1802 inline GDALAlgorithmArg &operator=(const std::vector<std::string> &value)
1803 {
1804 Set(value);
1805 return *this;
1806 }
1807
1810 {
1811 Set(value);
1812 return *this;
1813 }
1814
1816 GDALAlgorithmArg &operator=(std::unique_ptr<GDALDataset> value);
1817
1824 bool SetFrom(const GDALAlgorithmArg &other);
1825
1828 void SetSkipIfAlreadySet(bool skip = true)
1829 {
1830 m_skipIfAlreadySet = skip;
1831 }
1832
1835 bool SkipIfAlreadySet() const
1836 {
1837 return m_skipIfAlreadySet;
1838 }
1839
1844 bool Serialize(std::string &serializedArg, bool absolutePath = false) const;
1845
1847 static std::string GetEscapedString(const std::string &s);
1848
1850 void NotifyValueSet()
1851 {
1852 m_explicitlySet = true;
1853 }
1854
1856
1857 protected:
1858 friend class GDALAlgorithm;
1862 std::variant<bool *, std::string *, int *, double *, GDALArgDatasetValue *,
1863 std::vector<std::string> *, std::vector<int> *,
1864 std::vector<double> *, std::vector<GDALArgDatasetValue> *>
1865 m_value{};
1867 std::vector<std::function<void()>> m_actions{};
1869 std::vector<std::function<bool()>> m_validationActions{};
1871 std::function<std::vector<std::string>(const std::string &)>
1872 m_autoCompleteFunction{};
1874 GDALAlgorithm *m_owner = nullptr;
1875
1876 private:
1877 bool m_skipIfAlreadySet = false;
1878 bool m_explicitlySet = false;
1879
1880 template <class T> bool SetInternal(const T &value)
1881 {
1882 m_explicitlySet = true;
1883 *std::get<T *>(m_value) = value;
1884 return RunAllActions();
1885 }
1886
1887 bool ProcessString(std::string &value) const;
1888
1889 bool RunAllActions();
1890 void RunActions();
1891 bool RunValidationActions();
1892 std::string ValidateChoice(const std::string &value) const;
1893 bool ValidateIntRange(int val) const;
1894 bool ValidateRealRange(double val) const;
1895
1896 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
1897 ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
1898
1900};
1901
1902/************************************************************************/
1903/* GDALInConstructionAlgorithmArg */
1904/************************************************************************/
1905
1907namespace test_gdal_algorithm
1908{
1909struct test_gdal_algorithm;
1910}
1911
1913
1918{
1919 friend struct test_gdal_algorithm::test_gdal_algorithm;
1920
1921 public:
1923 template <class T>
1925 const GDALAlgorithmArgDecl &decl, T *pValue)
1926 : GDALAlgorithmArg(decl, pValue)
1927 {
1928 m_owner = owner;
1929 }
1930
1933
1935 GDALInConstructionAlgorithmArg &AddAlias(const std::string &alias);
1936
1938 GDALInConstructionAlgorithmArg &AddHiddenAlias(const std::string &alias);
1939
1941 GDALInConstructionAlgorithmArg &AddShortNameAlias(char shortNameAlias);
1942
1944 GDALInConstructionAlgorithmArg &SetPositional();
1945
1948 {
1949 m_decl.SetRequired();
1950 return *this;
1951 }
1952
1954 GDALInConstructionAlgorithmArg &SetMetaVar(const std::string &metaVar)
1955 {
1956 m_decl.SetMetaVar(metaVar);
1957 return *this;
1958 }
1959
1961 GDALInConstructionAlgorithmArg &SetCategory(const std::string &category)
1962 {
1963 m_decl.SetCategory(category);
1964 return *this;
1965 }
1966
1968 template <class T>
1970 {
1971 m_decl.SetDefault(value);
1972
1973 if constexpr (!std::is_same_v<T, GDALArgDatasetValue> &&
1974 !std::is_same_v<T, std::vector<GDALArgDatasetValue>>)
1975 {
1976 try
1977 {
1978 switch (m_decl.GetType())
1979 {
1980 case GAAT_BOOLEAN:
1981 *std::get<bool *>(m_value) = m_decl.GetDefault<bool>();
1982 break;
1983 case GAAT_STRING:
1984 *std::get<std::string *>(m_value) =
1985 m_decl.GetDefault<std::string>();
1986 break;
1987 case GAAT_INTEGER:
1988 *std::get<int *>(m_value) = m_decl.GetDefault<int>();
1989 break;
1990 case GAAT_REAL:
1991 *std::get<double *>(m_value) =
1992 m_decl.GetDefault<double>();
1993 break;
1994 case GAAT_STRING_LIST:
1995 *std::get<std::vector<std::string> *>(m_value) =
1996 m_decl.GetDefault<std::vector<std::string>>();
1997 break;
1998 case GAAT_INTEGER_LIST:
1999 *std::get<std::vector<int> *>(m_value) =
2000 m_decl.GetDefault<std::vector<int>>();
2001 break;
2002 case GAAT_REAL_LIST:
2003 *std::get<std::vector<double> *>(m_value) =
2004 m_decl.GetDefault<std::vector<double>>();
2005 break;
2006 case GAAT_DATASET:
2007 case GAAT_DATASET_LIST:
2008 break;
2009 }
2010 }
2011 catch (const std::bad_variant_access &)
2012 {
2013 // I don't think that can happen, but Coverity Scan thinks so
2014 CPLError(CE_Failure, CPLE_AppDefined,
2015 "Argument %s: SetDefault(): unexpected type for value",
2016 GetName().c_str());
2017 }
2018 }
2019 return *this;
2020 }
2021
2024 {
2025 return SetDefault(std::string(value));
2026 }
2027
2030 {
2031 m_decl.SetMinCount(count);
2032 return *this;
2033 }
2034
2037 {
2038 m_decl.SetMaxCount(count);
2039 return *this;
2040 }
2041
2045 {
2046 m_decl.SetDisplayHintAboutRepetition(displayHint);
2047 return *this;
2048 }
2049
2052 {
2053 m_decl.SetPackedValuesAllowed(allowed);
2054 return *this;
2055 }
2056
2059 {
2060 m_decl.SetRepeatedArgAllowed(allowed);
2061 return *this;
2062 }
2063
2066 {
2067 m_decl.SetDuplicateValuesAllowed(allowed);
2068 return *this;
2069 }
2070
2072 template <
2073 typename T, typename... U,
2074 typename std::enable_if<!std::is_same_v<T, std::vector<std::string> &>,
2075 bool>::type = true>
2077 {
2078 m_decl.SetChoices(std::forward<T>(first), std::forward<U>(rest)...);
2079 return *this;
2080 }
2081
2084 SetChoices(const std::vector<std::string> &choices)
2085 {
2086 m_decl.SetChoices(choices);
2087 return *this;
2088 }
2089
2091 template <typename T, typename... U>
2093 {
2094 m_decl.SetHiddenChoices(std::forward<T>(first),
2095 std::forward<U>(rest)...);
2096 return *this;
2097 }
2098
2101 {
2102 m_decl.SetMinValueIncluded(min);
2103 return *this;
2104 }
2105
2108 {
2109 m_decl.SetMinValueExcluded(min);
2110 return *this;
2111 }
2112
2115 {
2116 m_decl.SetMaxValueIncluded(max);
2117 return *this;
2118 }
2119
2122 {
2123 m_decl.SetMaxValueExcluded(max);
2124 return *this;
2125 }
2126
2129 {
2130 m_decl.SetMinCharCount(count);
2131 return *this;
2132 }
2133
2136 {
2137 m_decl.SetMaxCharCount(count);
2138 return *this;
2139 }
2140
2143 {
2144 m_decl.SetHidden();
2145 return *this;
2146 }
2147
2150 {
2151 m_decl.SetHiddenForCLI(hiddenForCLI);
2152 return *this;
2153 }
2154
2157 {
2158 m_decl.SetHiddenForAPI(hiddenForAPI);
2159 return *this;
2160 }
2161
2164 {
2165 m_decl.SetIsInput(isInput);
2166 return *this;
2167 }
2168
2171 {
2172 m_decl.SetIsOutput(isOutput);
2173 return *this;
2174 }
2175
2182
2189
2192 {
2193 m_decl.SetAutoOpenDataset(autoOpen);
2194 return *this;
2195 }
2196
2199 SetMutualExclusionGroup(const std::string &group)
2200 {
2201 m_decl.SetMutualExclusionGroup(group);
2202 return *this;
2203 }
2204
2207 SetMutualDependencyGroup(const std::string &group)
2208 {
2209 m_decl.SetMutualDependencyGroup(group);
2210 return *this;
2211 }
2212
2216 {
2217 m_decl.AddDirectDependency(otherArg.GetName());
2218 return *this;
2219 }
2220
2223 AddMetadataItem(const std::string &name,
2224 const std::vector<std::string> &values)
2225 {
2226 m_decl.AddMetadataItem(name, values);
2227 return *this;
2228 }
2229
2232 SetDatasetType(GDALArgDatasetType datasetType)
2233 {
2234 m_decl.SetDatasetType(datasetType);
2235 return *this;
2236 }
2237
2240 {
2241 m_decl.SetDatasetInputFlags(flags);
2242 return *this;
2243 }
2244
2247 {
2248 m_decl.SetDatasetOutputFlags(flags);
2249 return *this;
2250 }
2251
2256 {
2257 m_actions.push_back(f);
2258 return *this;
2259 }
2260
2268 {
2269 m_validationActions.push_back(f);
2270 return *this;
2271 }
2272
2277 std::function<std::vector<std::string>(const std::string &)> f)
2278 {
2279 m_autoCompleteFunction = std::move(f);
2280 return *this;
2281 }
2282
2290 SetIsCRSArg(bool noneAllowed = false,
2291 const std::vector<std::string> &specialValues =
2292 std::vector<std::string>());
2293
2296 {
2297 m_decl.SetAvailableInPipelineStep(available);
2298 return *this;
2299 }
2300
2303 {
2304 m_decl.SetUserProvided();
2305 return *this;
2306 }
2307};
2308
2309/************************************************************************/
2310/* GDALAlgorithmRegistry */
2311/************************************************************************/
2312
2316{
2317 public:
2320 static constexpr const char *HIDDEN_ALIAS_SEPARATOR = "==hide==";
2321
2322 virtual ~GDALAlgorithmRegistry();
2323
2326 {
2327 public:
2329 std::string m_name{};
2331 std::vector<std::string> m_aliases{};
2332#ifdef DOXYGEN_SKIP
2334 std::function m_creationFunc{};
2335#else
2337 std::function<std::unique_ptr<GDALAlgorithm>(void)> m_creationFunc{};
2338#endif
2339 };
2340
2343 template <class MyAlgorithm> bool Register()
2344 {
2345 AlgInfo info;
2346 info.m_name = MyAlgorithm::NAME;
2347 info.m_aliases = MyAlgorithm::GetAliasesStatic();
2348 info.m_creationFunc = []() -> std::unique_ptr<GDALAlgorithm>
2349 { return std::make_unique<MyAlgorithm>(); };
2350 return Register(info);
2351 }
2352
2355 bool Register(const AlgInfo &info);
2356
2362 std::vector<std::string> GetNames() const;
2363
2367 std::unique_ptr<GDALAlgorithm> Instantiate(const std::string &name) const;
2368
2373 std::unique_ptr<GDALAlgorithm>
2374 Instantiate(const std::vector<std::string> &path) const;
2375
2380 template <typename... V>
2381 inline std::unique_ptr<GDALAlgorithm> Instantiate(const std::string &first,
2382 V &&...rest)
2383 {
2384 std::vector<std::string> path;
2385 return InstantiateInternal(path, first, std::forward<V>(rest)...);
2386 }
2387
2389 const AlgInfo *GetInfo(const std::string &name) const
2390 {
2391 auto iter = m_mapNameToInfo.find(name);
2392 return iter != m_mapNameToInfo.end() ? &(iter->second) : nullptr;
2393 }
2394
2396 bool empty() const
2397 {
2398 return m_mapNameToInfo.empty();
2399 }
2400
2401 protected:
2403 virtual std::unique_ptr<GDALAlgorithm>
2404 InstantiateTopLevel(const std::string &name) const;
2405
2406 private:
2407 std::map<std::string, AlgInfo> m_mapNameToInfo{};
2408 std::map<std::string, AlgInfo> m_mapAliasToInfo{};
2409 std::map<std::string, AlgInfo> m_mapHiddenAliasToInfo{};
2410
2411 std::unique_ptr<GDALAlgorithm>
2412 InstantiateInternal(std::vector<std::string> &path);
2413
2414 template <typename... V>
2415 std::unique_ptr<GDALAlgorithm>
2416 InstantiateInternal(std::vector<std::string> &path,
2417 const std::string &first, V &&...rest)
2418 {
2419 path.push_back(first);
2420 return InstantiateInternal(path, std::forward<V>(rest)...);
2421 }
2422};
2423
2424/************************************************************************/
2425/* GDALAlgorithm */
2426/************************************************************************/
2427
2444/* abstract */ class CPL_DLL GDALAlgorithm
2445{
2446 friend struct test_gdal_algorithm::test_gdal_algorithm;
2447
2448 public:
2449 virtual ~GDALAlgorithm();
2450
2452 const std::string &GetName() const
2453 {
2454 return m_name;
2455 }
2456
2458 const std::string &GetDescription() const
2459 {
2460 return m_description;
2461 }
2462
2464 const std::string &GetLongDescription() const
2465 {
2466 return m_longDescription;
2467 }
2468
2472 const std::string &GetHelpURL() const
2473 {
2474 return m_helpURL;
2475 }
2476
2478 const std::string &GetHelpFullURL() const
2479 {
2480 return m_helpFullURL;
2481 }
2482
2484 bool IsHidden() const
2485 {
2486 return m_hidden;
2487 }
2488
2490 bool HasSubAlgorithms() const;
2491
2497 std::vector<std::string> GetSubAlgorithmNames() const;
2498
2500 std::unique_ptr<GDALAlgorithm>
2501 InstantiateSubAlgorithm(const std::string &name,
2502 bool suggestionAllowed = true) const;
2503
2505 const std::vector<std::unique_ptr<GDALAlgorithmArg>> &GetArgs() const
2506 {
2507 return m_args;
2508 }
2509
2511 std::vector<std::unique_ptr<GDALAlgorithmArg>> &GetArgs()
2512 {
2513 return m_args;
2514 }
2515
2517 std::string GetSuggestionForArgumentName(const std::string &osName) const;
2518
2520 GDALAlgorithmArg *GetArg(const std::string &osName,
2521 bool suggestionAllowed = false)
2522 {
2523 return GetArg(osName, suggestionAllowed, /* isConst = */ false);
2524 }
2525
2527 GDALAlgorithmArg &operator[](const std::string &osName)
2528 {
2529 auto alg = GetArg(osName, false);
2530 if (!alg)
2531 {
2532 ReportError(CE_Failure, CPLE_AppDefined,
2533 "Argument '%s' does not exist", osName.c_str());
2534 return m_dummyArg;
2535 }
2536 return *alg;
2537 }
2538
2540 const GDALAlgorithmArg *GetArg(const std::string &osName,
2541 bool suggestionAllowed = false) const
2542 {
2543 return const_cast<GDALAlgorithm *>(this)->GetArg(
2544 osName, suggestionAllowed, /* isConst = */ true);
2545 }
2546
2548 const GDALAlgorithmArg &operator[](const std::string &osName) const
2549 {
2550 const auto alg = GetArg(osName, false);
2551 if (!alg)
2552 {
2553 ReportError(CE_Failure, CPLE_AppDefined,
2554 "Argument '%s' does not exist", osName.c_str());
2555 return m_dummyArg;
2556 }
2557 return *alg;
2558 }
2559
2562 std::vector<std::string>
2563 GetArgDependencies(const std::string &osName) const;
2564
2570 void SetCallPath(const std::vector<std::string> &path)
2571 {
2572 m_callPath = path;
2573 }
2574
2580 {
2581 m_parseForAutoCompletion = true;
2582 }
2583
2588 void SetReferencePathForRelativePaths(const std::string &referencePath)
2589 {
2590 m_referencePath = referencePath;
2591 }
2592
2594 const std::string &GetReferencePathForRelativePaths() const
2595 {
2596 return m_referencePath;
2597 }
2598
2601 {
2602 return m_supportsStreamedOutput;
2603 }
2604
2613 {
2614 m_executionForStreamOutput = true;
2615 }
2616
2620 virtual bool
2621 ParseCommandLineArguments(const std::vector<std::string> &args);
2622
2632 virtual bool ValidateArguments();
2633
2639 bool Run(GDALProgressFunc pfnProgress = nullptr,
2640 void *pProgressData = nullptr);
2641
2645 virtual bool Finalize();
2646
2649 {
2656
2657 UsageOptions()
2658 : isPipelineStep(false), maxOptLen(0), isPipelineMain(false)
2659 {
2660 }
2661 };
2662
2666 virtual std::string
2667 GetUsageForCLI(bool shortUsage,
2668 const UsageOptions &usageOptions = UsageOptions()) const;
2669
2674 virtual std::string GetUsageAsJSON() const;
2675
2682 {
2683 if (m_selectedSubAlg)
2684 return m_selectedSubAlg->GetActualAlgorithm();
2685 return *this;
2686 }
2687
2689 bool IsHelpRequested() const
2690 {
2691 return m_helpRequested;
2692 }
2693
2696 {
2697 return m_JSONUsageRequested;
2698 }
2699
2702 {
2703 if (m_selectedSubAlg)
2704 return m_selectedSubAlg->IsProgressBarRequested();
2705 return m_progressBarRequested;
2706 }
2707
2709 const std::vector<std::string> &GetAliases() const
2710 {
2711 return m_aliases;
2712 }
2713
2715
2718 static std::vector<std::string> GetAliasesStatic()
2719 {
2720 return {};
2721 }
2722
2724
2730 {
2731 target->m_calledFromCommandLine = m_calledFromCommandLine;
2732 target->m_progressBarRequested = m_progressBarRequested;
2733 target->m_quiet = m_quiet;
2734 if (m_specialActionRequested)
2735 {
2736 target->m_specialActionRequested = m_specialActionRequested;
2737 target->m_helpRequested = m_helpRequested;
2738 target->m_helpDocRequested = m_helpDocRequested;
2739 target->m_JSONUsageRequested = m_JSONUsageRequested;
2740 return true;
2741 }
2742 return false;
2743 }
2744
2746 virtual std::vector<std::string>
2747 GetAutoComplete(std::vector<std::string> &args, bool lastWordIsComplete,
2748 bool showAllOptions);
2749
2752 {
2753 m_calledFromCommandLine = true;
2754 }
2755
2758 {
2759 return m_calledFromCommandLine;
2760 }
2761
2763 virtual bool HasOutputString() const;
2764
2768 static bool SaveGDALG(const std::string &filename, std::string &outString,
2769 const std::string &commandLine);
2770
2772 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
2773 ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
2775
2776 protected:
2777 friend class GDALInConstructionAlgorithmArg;
2778 friend class GDALRasterReprojectUtils;
2779
2782 GDALAlgorithm *m_selectedSubAlg = nullptr;
2783
2787 std::vector<std::string> m_callPath{};
2788
2790 std::string m_longDescription{};
2791
2793 bool m_progressBarRequested = true;
2794
2796 bool m_quiet = false;
2797
2799 bool m_skipValidationInParseCommandLine = false;
2800
2804 bool m_inputDatasetCanBeOmitted = false;
2805
2806 friend class GDALAlgorithmRegistry; // to set m_aliases
2808 std::vector<std::string> m_aliases{};
2809
2811 bool m_supportsStreamedOutput = false;
2812
2814 bool m_executionForStreamOutput = false;
2815
2817 bool m_hidden = false;
2818
2820 bool m_alreadyRun = false;
2821
2823 std::map<std::string, GDALDataset *> m_oMapDatasetNameToDataset{};
2824
2826 GDALAlgorithm(const std::string &name, const std::string &description,
2827 const std::string &helpURL);
2828
2830 bool ProcessDatasetArg(GDALAlgorithmArg *arg, GDALAlgorithm *algForOutput);
2831
2834 template <class MyAlgorithm> bool RegisterSubAlgorithm()
2835 {
2836 return m_subAlgRegistry.Register<MyAlgorithm>();
2837 }
2838
2842 {
2843 return m_subAlgRegistry.Register(info);
2844 }
2845
2848 {
2849 m_arbitraryLongNameArgsAllowed = true;
2850 }
2851
2853 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2854 char chShortName,
2855 const std::string &helpMessage,
2856 bool *pValue);
2857
2859 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2860 char chShortName,
2861 const std::string &helpMessage,
2862 std::string *pValue);
2863
2865 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2866 char chShortName,
2867 const std::string &helpMessage,
2868 int *pValue);
2869
2871 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2872 char chShortName,
2873 const std::string &helpMessage,
2874 double *pValue);
2875
2877 static void
2878 SetAutoCompleteFunctionForFilename(GDALInConstructionAlgorithmArg &arg,
2879 GDALArgDatasetType type);
2880
2883 AddArg(const std::string &longName, char chShortName,
2884 const std::string &helpMessage, GDALArgDatasetValue *pValue,
2885 GDALArgDatasetType type = GDAL_OF_RASTER | GDAL_OF_VECTOR |
2887
2889 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2890 char chShortName,
2891 const std::string &helpMessage,
2892 std::vector<std::string> *pValue);
2893
2895 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2896 char chShortName,
2897 const std::string &helpMessage,
2898 std::vector<int> *pValue);
2899
2901 GDALInConstructionAlgorithmArg &AddArg(const std::string &longName,
2902 char chShortName,
2903 const std::string &helpMessage,
2904 std::vector<double> *pValue);
2905
2908 AddArg(const std::string &longName, char chShortName,
2909 const std::string &helpMessage,
2910 std::vector<GDALArgDatasetValue> *pValue,
2911 GDALArgDatasetType type = GDAL_OF_RASTER | GDAL_OF_VECTOR |
2913
2915 GDALInConstructionAlgorithmArg &AddInputDatasetArg(
2916 GDALArgDatasetValue *pValue,
2917 GDALArgDatasetType type = GDAL_OF_RASTER | GDAL_OF_VECTOR |
2919 bool positionalAndRequired = true, const char *helpMessage = nullptr);
2920
2922 GDALInConstructionAlgorithmArg &AddInputDatasetArg(
2923 std::vector<GDALArgDatasetValue> *pValue,
2924 GDALArgDatasetType type = GDAL_OF_RASTER | GDAL_OF_VECTOR |
2926 bool positionalAndRequired = true, const char *helpMessage = nullptr);
2927
2930 AddOpenOptionsArg(std::vector<std::string> *pValue,
2931 const char *helpMessage = nullptr);
2932
2935 AddOutputOpenOptionsArg(std::vector<std::string> *pValue,
2936 const char *helpMessage = nullptr);
2937
2940 AddInputFormatsArg(std::vector<std::string> *pValue,
2941 const char *helpMessage = nullptr);
2942
2944 GDALInConstructionAlgorithmArg &AddOutputDatasetArg(
2945 GDALArgDatasetValue *pValue,
2946 GDALArgDatasetType type = GDAL_OF_RASTER | GDAL_OF_VECTOR |
2948 bool positionalAndRequired = true, const char *helpMessage = nullptr);
2949
2952 AddOverwriteArg(bool *pValue, const char *helpMessage = nullptr);
2953
2956 AddOverwriteLayerArg(bool *pValue, const char *helpMessage = nullptr);
2957
2960 AddUpdateArg(bool *pValue, const char *helpMessage = nullptr);
2961
2964 AddAppendLayerArg(bool *pValue, const char *helpMessage = nullptr);
2965
2968 AddOutputStringArg(std::string *pValue, const char *helpMessage = nullptr);
2969
2972 AddStdoutArg(bool *pValue, const char *helpMessage = nullptr);
2973
2976 AddOutputFormatArg(std::string *pValue, bool bStreamAllowed = false,
2977 bool bGDALGAllowed = false,
2978 const char *helpMessage = nullptr);
2979
2982 AddOutputDataTypeArg(std::string *pValue,
2983 const char *helpMessage = nullptr);
2984
2987 AddNodataArg(std::string *pValue, bool noneAllowed,
2988 const std::string &optionName = "nodata",
2989 const char *helpMessage = nullptr);
2990
2993 AddCreationOptionsArg(std::vector<std::string> *pValue,
2994 const char *helpMessage = nullptr);
2995
2998 AddLayerCreationOptionsArg(std::vector<std::string> *pValue,
2999 const char *helpMessage = nullptr);
3000
3003 AddLayerNameArg(std::string *pValue, const char *helpMessage = nullptr);
3004
3007 AddOutputLayerNameArg(std::string *pValue,
3008 const char *helpMessage = nullptr);
3009
3012 AddLayerNameArg(std::vector<std::string> *pValue,
3013 const char *helpMessage = nullptr);
3014
3017 AddArrayNameArg(std::string *pValue, const char *helpMessage = nullptr);
3018
3021 AddArrayNameArg(std::vector<std::string> *pValue,
3022 const char *helpMessage = nullptr);
3023
3029 AddMemorySizeArg(size_t *pValue, std::string *pStrValue,
3030 const std::string &optionName, const char *helpMessage);
3031
3034 AddGeometryTypeArg(std::string *pValue, const char *helpMessage = nullptr);
3035
3037 static void SetAutoCompleteFunctionForLayerName(
3038 GDALInConstructionAlgorithmArg &layerArg, GDALAlgorithmArg &datasetArg);
3039
3041 static void SetAutoCompleteFunctionForFieldName(
3043 const GDALAlgorithmArg *layerNameArg, bool attributeFields,
3044 bool geometryFields, std::vector<GDALArgDatasetValue> &datasetArg);
3045
3048 AddFieldNameArg(std::string *pValue, const char *helpMessage = nullptr);
3049
3057 static bool ParseFieldDefinition(const std::string &osStrDef,
3058 OGRFieldDefn *poFieldDefn,
3059 std::string *posError);
3060
3069 AddFieldDefinitionArg(std::vector<std::string> *pValues,
3070 std::vector<OGRFieldDefn> *pFieldDefns,
3071 const char *helpMessage = nullptr);
3072
3074 GDALInConstructionAlgorithmArg &AddFieldTypeSubtypeArg(
3075 OGRFieldType *pTypeValue, OGRFieldSubType *pSubtypeValue,
3076 std::string *pStrValue, const std::string &argName = std::string(),
3077 const char *helpMessage = nullptr);
3078
3081 AddBandArg(int *pValue, const char *helpMessage = nullptr);
3082
3085 AddBandArg(std::vector<int> *pValue, const char *helpMessage = nullptr);
3086
3089 AddBBOXArg(std::vector<double> *pValue, const char *helpMessage = nullptr);
3090
3093 AddActiveLayerArg(std::string *pValue, const char *helpMessage = nullptr);
3094
3100 AddNumThreadsArg(int *pValue, std::string *pStrValue,
3101 const char *helpMessage = nullptr);
3102
3105 AddAbsolutePathArg(bool *pValue, const char *helpMessage = nullptr);
3106
3109 AddPixelFunctionNameArg(std::string *pValue,
3110 const char *helpMessage = nullptr);
3111
3114 AddPixelFunctionArgsArg(std::vector<std::string> *pValue,
3115 const char *helpMessage = nullptr);
3116
3118 void AddProgressArg();
3119
3126 void AddValidationAction(std::function<bool()> f)
3127 {
3128 m_validationActions.push_back(f);
3129 }
3130
3132 static bool AddOptionsSuggestions(const char *pszXML, int datasetType,
3133 const std::string &currentValue,
3134 std::vector<std::string> &oRet);
3135
3137 bool ParseAndValidateKeyValue(GDALAlgorithmArg &arg);
3138
3140 bool RunPreStepPipelineValidations() const;
3141
3143 bool IsGDALGOutput() const;
3144
3147 {
3149 GDALG_OK,
3151 GDALG_ERROR,
3153 NOT_GDALG,
3154 };
3155
3157 virtual ProcessGDALGOutputRet ProcessGDALGOutput();
3158
3162 virtual bool CheckSafeForStreamOutput();
3163
3165 bool ValidateFormat(const GDALAlgorithmArg &arg, bool bStreamAllowed,
3166 bool bGDALGAllowed) const;
3167
3169 static std::vector<std::string>
3170 FormatAutoCompleteFunction(const GDALAlgorithmArg &arg, bool bStreamAllowed,
3171 bool bGDALGAllowed);
3172
3174 void AddAliasFor(GDALInConstructionAlgorithmArg *arg,
3175 const std::string &alias);
3176
3177 void AddShortNameAliasFor(GDALInConstructionAlgorithmArg *arg,
3178 char shortNameAlias);
3179
3180 void SetPositional(GDALInConstructionAlgorithmArg *arg);
3181
3182 std::vector<std::string>
3183 OpenOptionCompleteFunction(const std::string &currentValue) const;
3184
3186
3188 static bool IsKnownOutputRelatedBooleanArgName(std::string_view osName);
3189
3192 {
3193 m_displayInJSONUsage = b;
3194 }
3195
3199 virtual void WarnIfDeprecated()
3200 {
3201 }
3202
3204 std::pair<std::vector<std::pair<GDALAlgorithmArg *, std::string>>, size_t>
3205 GetArgNamesForCLI() const;
3206
3208 static bool GetFieldIndices(const std::vector<std::string> &osFieldNames,
3209 OGRLayerH hLayer, std::vector<int> &anIndices);
3210
3212 std::string GetUsageForCLIEnd() const;
3214
3215 private:
3216 const std::string m_name{};
3217 const std::string m_description{};
3218 const std::string m_helpURL{};
3219 const std::string m_helpFullURL{};
3220 bool m_parsedSubStringAlreadyCalled = false;
3221 bool m_displayInJSONUsage = true;
3222 bool m_specialActionRequested = false;
3223 bool m_helpRequested = false;
3224 bool m_calledFromCommandLine = false;
3225
3226 // Used by program-output directives in .rst files
3227 bool m_helpDocRequested = false;
3228
3229 bool m_JSONUsageRequested = false;
3230 bool m_parseForAutoCompletion = false;
3231 std::string m_referencePath{};
3232 std::vector<std::string> m_dummyConfigOptions{};
3233 std::vector<std::unique_ptr<GDALAlgorithmArg>> m_args{};
3234 std::map<std::string, GDALAlgorithmArg *> m_mapLongNameToArg{};
3235 std::map<std::string, GDALAlgorithmArg *> m_mapShortNameToArg{};
3236 std::vector<GDALAlgorithmArg *> m_positionalArgs{};
3237 GDALAlgorithmRegistry m_subAlgRegistry{};
3238 std::unique_ptr<GDALAlgorithm> m_selectedSubAlgHolder{};
3239 std::function<std::vector<std::string>(const std::vector<std::string> &)>
3240 m_autoCompleteFunction{};
3241 std::vector<std::function<bool()>> m_validationActions{};
3242
3243 std::string m_dummyVal{};
3244 GDALAlgorithmArg m_dummyArg{
3245 GDALAlgorithmArgDecl("dummy", 0, "", GAAT_STRING), &m_dummyVal};
3246
3250 bool m_arbitraryLongNameArgsAllowed = false;
3251
3252 std::vector<std::unique_ptr<std::string>>
3253 m_arbitraryLongNameArgsValuesStr{};
3254 std::vector<std::unique_ptr<bool>> m_arbitraryLongNameArgsValuesBool{};
3255
3256 friend GDALAlgorithmArgH GDALAlgorithmGetArg(GDALAlgorithmH hAlg,
3257 const char *pszArgName);
3258 friend GDALAlgorithmArgH
3259 GDALAlgorithmGetArgNonConst(GDALAlgorithmH hAlg, const char *pszArgName);
3260 GDALAlgorithmArg *GetArg(const std::string &osName, bool suggestionAllowed,
3261 bool isConst);
3262
3264 AddArg(std::unique_ptr<GDALInConstructionAlgorithmArg> arg);
3265 bool ParseArgument(
3266 GDALAlgorithmArg *arg, const std::string &name,
3267 const std::string &value,
3268 std::map<
3270 std::variant<std::vector<std::string>, std::vector<int>,
3271 std::vector<double>, std::vector<GDALArgDatasetValue>>>
3272 &inConstructionValues);
3273
3274 bool ValidateBandArg() const;
3275
3276 virtual bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) = 0;
3277
3281 void ExtractLastOptionAndValue(std::vector<std::string> &args,
3282 std::string &option,
3283 std::string &value) const;
3284
3285 std::vector<std::string> AutoCompleteArrayName() const;
3286
3287 GDALAlgorithm(const GDALAlgorithm &) = delete;
3288 GDALAlgorithm &operator=(const GDALAlgorithm &) = delete;
3289};
3290
3292struct GDALAlgorithmHS
3293{
3294 private:
3295 std::unique_ptr<GDALAlgorithm> uniquePtr{};
3296
3297 GDALAlgorithmHS(const GDALAlgorithmHS &) = delete;
3298 GDALAlgorithmHS &operator=(const GDALAlgorithmHS &) = delete;
3299
3300 public:
3301 GDALAlgorithm *ptr = nullptr;
3302
3303 GDALAlgorithmHS() = default;
3304
3305 explicit GDALAlgorithmHS(std::unique_ptr<GDALAlgorithm> alg)
3306 : uniquePtr(std::move(alg)), ptr(uniquePtr.get())
3307 {
3308 }
3309
3310 static std::unique_ptr<GDALAlgorithmHS> FromRef(GDALAlgorithm &alg)
3311 {
3312 auto ret = std::make_unique<GDALAlgorithmHS>();
3313 ret->ptr = &alg;
3314 return ret;
3315 }
3316};
3317
3318/************************************************************************/
3319/* GDALContainerAlgorithm */
3320/************************************************************************/
3321
3322class CPL_DLL GDALContainerAlgorithm : public GDALAlgorithm
3323{
3324 public:
3325 explicit GDALContainerAlgorithm(
3326 const std::string &name, const std::string &description = std::string(),
3327 const std::string &helpURL = std::string())
3328 : GDALAlgorithm(name, description, helpURL)
3329 {
3330 }
3331
3332 protected:
3333 bool RunImpl(GDALProgressFunc, void *) override;
3334};
3335
3337
3338/************************************************************************/
3339/* GDALGlobalAlgorithmRegistry */
3340/************************************************************************/
3341
3345{
3346 public:
3348 static constexpr const char *ROOT_ALG_NAME = "gdal";
3349
3351 static GDALGlobalAlgorithmRegistry &GetSingleton();
3352
3354 using InstantiateFunc = std::function<std::unique_ptr<GDALAlgorithm>()>;
3355
3362 void DeclareAlgorithm(const std::vector<std::string> &path,
3363 InstantiateFunc instantiateFunc);
3364
3367 std::vector<std::string>
3368 GetDeclaredSubAlgorithmNames(const std::vector<std::string> &path) const;
3369
3371 bool HasDeclaredSubAlgorithm(const std::vector<std::string> &path) const;
3372
3374 std::unique_ptr<GDALAlgorithm>
3375 InstantiateDeclaredSubAlgorithm(const std::vector<std::string> &path) const;
3376
3377 protected:
3378 std::unique_ptr<GDALAlgorithm>
3379 InstantiateTopLevel(const std::string &name) const override;
3380
3381 private:
3382 struct Node
3383 {
3384 InstantiateFunc instantiateFunc{};
3385 std::map<std::string, Node> children{};
3386 };
3387
3388 Node m_root{};
3389
3392
3393 const Node *GetNodeFromPath(const std::vector<std::string> &path) const;
3394};
3395
3396#endif // #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && (defined(DOXYGEN_SKIP) || __cplusplus >= 201703L || _MSC_VER >= 1920)
3397
3398#endif // GDAL_ALGORITHM_CPP_INCLUDED
Argument declaration.
Definition gdalalgorithm_cpp.h:313
const std::string & GetCategory() const
Return the argument category: GAAC_COMMON, GAAC_BASE, GAAC_ADVANCED, GAAC_ESOTERIC or a custom catego...
Definition gdalalgorithm_cpp.h:847
std::pair< double, bool > GetMaxValue() const
Return the maximum value and whether it is included.
Definition gdalalgorithm_cpp.h:881
GDALAlgorithmArgDecl & AddShortNameAlias(char shortNameAlias)
Declare a shortname alias.
Definition gdalalgorithm_cpp.h:339
bool GetPackedValuesAllowed() const
Return whether, for list type of arguments, several values, space separated, may be specified.
Definition gdalalgorithm_cpp.h:938
GDALAlgorithmArgDecl & SetReadFromFileAtSyntaxAllowed()
Set that this (string) argument accepts the @filename syntax to mean that the content of the specifie...
Definition gdalalgorithm_cpp.h:773
int GetDatasetOutputFlags() const
Indicates which components among name and dataset are modified, when this argument serves as an outpu...
Definition gdalalgorithm_cpp.h:1163
int GetMaxCount() const
Return the maximum number of values for the argument.
Definition gdalalgorithm_cpp.h:921
GDALAlgorithmArgDecl & SetDuplicateValuesAllowed(bool allowed)
Declares whether, for list type of arguments, there might be duplicate values in the list.
Definition gdalalgorithm_cpp.h:554
bool GetDuplicateValuesAllowed() const
Return whether, for list type of arguments, duplicated values in the list are allowed.
Definition gdalalgorithm_cpp.h:956
bool IsOutput() const
Return whether (at least part of) the value of the argument is set during the execution of the algori...
Definition gdalalgorithm_cpp.h:1023
GDALAlgorithmArgDecl & SetMinCount(int count)
Declare the minimum number of values for the argument.
Definition gdalalgorithm.cpp:195
GDALAlgorithmArgDecl & SetPackedValuesAllowed(bool allowed)
Declares whether, for list type of arguments, several values, comma separated, may be specified.
Definition gdalalgorithm_cpp.h:534
bool IsOnlyForCLI() const
Return whether the argument is only for CLI usage.
Definition gdalalgorithm_cpp.h:993
GDALAlgorithmArgDecl & SetMaxCount(int count)
Declare the maximum number of values for the argument.
Definition gdalalgorithm.cpp:214
void SetAvailableInPipelineStep(bool available)
Set whether the argument is available in a pipeline step.
Definition gdalalgorithm_cpp.h:1190
bool HasDefaultValue() const
Return if the argument has a declared default value.
Definition gdalalgorithm_cpp.h:968
const std::string & GetShortName() const
Return the short name, or empty string if there is none.
Definition gdalalgorithm_cpp.h:812
GDALAlgorithmArgDecl & SetMaxCharCount(int count)
Sets the maximum number of characters (for arguments of type GAAT_STRING and GAAT_STRING_LIST)
Definition gdalalgorithm_cpp.h:643
void SetDatasetOutputFlags(int flags)
Set which components among name and dataset are modified when this argument serves as an output.
Definition gdalalgorithm_cpp.h:1181
GDALAlgorithmArgDecl & SetHiddenChoices(T &&first, U &&...rest)
Declares the, hidden, allowed values (as strings) for the argument.
Definition gdalalgorithm_cpp.h:661
GDALAlgorithmArgDecl & SetDefault(const char *value)
Declare a default value for the argument.
Definition gdalalgorithm_cpp.h:502
GDALAlgorithmArgType GetType() const
Return the type.
Definition gdalalgorithm_cpp.h:853
const std::vector< std::string > & GetHiddenChoices() const
Return the allowed hidden values (as strings) for the argument.
Definition gdalalgorithm_cpp.h:869
bool IsHidden() const
Return whether the argument is hidden.
Definition gdalalgorithm_cpp.h:975
GDALAlgorithmArgDecl & SetMutualDependencyGroup(const std::string &group)
Set the name of the mutual dependency group to which this argument belongs to.
Definition gdalalgorithm_cpp.h:736
bool IsInput() const
Indicate whether the value of the argument is read-only during the execution of the algorithm.
Definition gdalalgorithm_cpp.h:1009
GDALAlgorithmArgDecl & SetMaxValueIncluded(double max)
Set the maximum (included) value allowed.
Definition gdalalgorithm_cpp.h:616
bool IsHiddenForAPI() const
Return whether the argument is hidden for API usage For example "--help".
Definition gdalalgorithm_cpp.h:1001
GDALAlgorithmArgDecl & SetHiddenForAPI(bool hiddenForAPI=true)
Declare that the argument is hidden in the context of an API use.
Definition gdalalgorithm_cpp.h:681
const std::string & GetMetaVar() const
Return the "meta-var" hint.
Definition gdalalgorithm_cpp.h:839
bool GetDisplayHintAboutRepetition() const
Returns whether in --help message one should display hints about the minimum/maximum number of values...
Definition gdalalgorithm_cpp.h:929
const std::vector< std::string > & GetAliases() const
Return the aliases (potentially none)
Definition gdalalgorithm_cpp.h:818
bool IsPositional() const
Return if the argument is a positional one.
Definition gdalalgorithm_cpp.h:962
GDALAlgorithmArgDecl & SetMaxValueExcluded(double max)
Set the maximum (excluded) value allowed.
Definition gdalalgorithm_cpp.h:624
void SetDatasetType(GDALArgDatasetType type)
Set which type of dataset is allowed / generated.
Definition gdalalgorithm_cpp.h:1132
bool IsRequired() const
Return whether the argument is required.
Definition gdalalgorithm_cpp.h:904
bool IsRemoveSQLCommentsEnabled() const
Returns whether SQL comments must be removed from a (string) argument.
Definition gdalalgorithm_cpp.h:1063
GDALAlgorithmArgDecl & SetMutualExclusionGroup(const std::string &group)
Set the name of the mutual exclusion group to which this argument belongs to.
Definition gdalalgorithm_cpp.h:724
int GetMinCount() const
Return the minimum number of values for the argument.
Definition gdalalgorithm_cpp.h:912
GDALAlgorithmArgDecl & SetCategory(const std::string &category)
Declare the argument category: GAAC_COMMON, GAAC_BASE, GAAC_ADVANCED, GAAC_ESOTERIC or a custom categ...
Definition gdalalgorithm_cpp.h:382
const std::vector< std::string > & GetDirectDependencies() const
Return the list of names of arguments that this argument directly depends on.
Definition gdalalgorithm_cpp.h:1047
GDALAlgorithmArgDecl & SetChoices(T &&first, U &&...rest)
Declares the allowed values (as strings) for the argument.
Definition gdalalgorithm_cpp.h:575
const std::vector< std::string > * GetMetadataItem(const std::string &name) const
Get user-defined metadata by item name.
Definition gdalalgorithm_cpp.h:1092
bool GetRepeatedArgAllowed() const
Return whether, for list type of arguments, the argument may be repeated.
Definition gdalalgorithm_cpp.h:947
bool IsAvailableInPipelineStep() const
Return whether the argument is available in a pipeline step.
Definition gdalalgorithm_cpp.h:1199
GDALAlgorithmArgDecl & SetIsInput(bool isInput=true)
Indicate whether the value of the argument is read-only during the execution of the algorithm.
Definition gdalalgorithm_cpp.h:700
void SetDatasetInputFlags(int flags)
Set which components among name and dataset are accepted as input, when this argument serves as an in...
Definition gdalalgorithm_cpp.h:1172
GDALAlgorithmArgDecl & SetRepeatedArgAllowed(bool allowed)
Declares whether, for list type of arguments, the argument may be repeated.
Definition gdalalgorithm_cpp.h:544
int GetMinCharCount() const
Return the minimum number of characters (for arguments of type GAAT_STRING and GAAT_STRING_LIST)
Definition gdalalgorithm_cpp.h:889
const std::vector< char > & GetShortNameAliases() const
Return the shortname aliases (potentially none)
Definition gdalalgorithm_cpp.h:824
const std::string & GetMutualExclusionGroup() const
Return the name of the mutual exclusion group to which this argument belongs to, or empty string if i...
Definition gdalalgorithm_cpp.h:1032
GDALAlgorithmArgDecl & SetMinCharCount(int count)
Sets the minimum number of characters (for arguments of type GAAT_STRING and GAAT_STRING_LIST)
Definition gdalalgorithm_cpp.h:634
bool IsReadFromFileAtSyntaxAllowed() const
Return if this (string) argument accepts the @filename syntax to mean that the content of the specifi...
Definition gdalalgorithm_cpp.h:1056
GDALAlgorithmArgDecl & AddAlias(const std::string &alias)
Declare an alias.
Definition gdalalgorithm_cpp.h:332
bool IsHiddenForCLI() const
Return whether the argument must not be mentioned in CLI usage.
Definition gdalalgorithm_cpp.h:984
GDALAlgorithmArgDecl & SetPositional()
Declare that the argument is positional.
Definition gdalalgorithm_cpp.h:355
GDALArgDatasetType GetDatasetType() const
Get which type of dataset is allowed / generated.
Definition gdalalgorithm_cpp.h:1122
GDALAlgorithmArgDecl & SetRequired()
Declare that the argument is required.
Definition gdalalgorithm_cpp.h:363
GDALAlgorithmArgDecl & SetUserProvided()
Declares that this argument has been created on-the-fly from user-provided argument.
Definition gdalalgorithm_cpp.h:799
const std::vector< std::string > & GetChoices() const
Return the allowed values (as strings) for the argument.
Definition gdalalgorithm_cpp.h:861
const std::string & GetMutualDependencyGroup() const
Returns the mutual dependency group name, or empty string if it doesn't belong to any group.
Definition gdalalgorithm_cpp.h:743
bool AutoOpenDataset() const
Returns whether the dataset should be opened automatically by GDALAlgorithm.
Definition gdalalgorithm_cpp.h:1071
GDALAlgorithmArgDecl & SetMetaVar(const std::string &metaVar)
Declare the "meta-var" hint.
Definition gdalalgorithm_cpp.h:373
bool IsUserProvided() const
Returns whether the argument has been user-provided.
Definition gdalalgorithm_cpp.h:1078
std::pair< double, bool > GetMinValue() const
Return the minimum value and whether it is included.
Definition gdalalgorithm_cpp.h:875
GDALAlgorithmArgDecl & AddMetadataItem(const std::string &name, const std::vector< std::string > &values)
Set user-defined metadata item.
Definition gdalalgorithm_cpp.h:762
int GetDatasetInputFlags() const
Indicates which components among name and dataset are accepted as input, when this argument serves as...
Definition gdalalgorithm_cpp.h:1148
const T & GetDefault() const
Return the default value of the argument.
Definition gdalalgorithm_cpp.h:1112
const std::string & GetDescription() const
Return the description.
Definition gdalalgorithm_cpp.h:830
GDALAlgorithmArgDecl & AddHiddenAlias(const std::string &alias)
Declare an hidden alias (i.e.
Definition gdalalgorithm_cpp.h:347
GDALAlgorithmArgDecl & SetMinValueIncluded(double min)
Set the minimum (included) value allowed.
Definition gdalalgorithm_cpp.h:596
GDALAlgorithmArgDecl & SetDefault(const T &value)
Declare a default value for the argument.
Definition gdalalgorithm_cpp.h:390
GDALAlgorithmArgDecl & SetChoices(const std::vector< std::string > &choices)
Declares the allowed values (as strings) for the argument.
Definition gdalalgorithm_cpp.h:585
GDALAlgorithmArgDecl & SetHiddenForCLI(bool hiddenForCLI=true)
Declare that the argument must not be mentioned in CLI usage.
Definition gdalalgorithm_cpp.h:672
GDALAlgorithmArgDecl & SetIsOutput(bool isOutput=true)
Indicate whether (at least part of) the value of the argument is set during the execution of the algo...
Definition gdalalgorithm_cpp.h:715
GDALAlgorithmArgDecl & SetAutoOpenDataset(bool autoOpen)
Sets whether the dataset should be opened automatically by GDALAlgorithm.
Definition gdalalgorithm_cpp.h:790
GDALAlgorithmArgDecl & SetDisplayHintAboutRepetition(bool displayHint)
Declare whether in --help message one should display hints about the minimum/maximum number of values...
Definition gdalalgorithm_cpp.h:524
GDALAlgorithmArgDecl & SetHidden()
Declare that the argument is hidden.
Definition gdalalgorithm_cpp.h:690
const std::string & GetName() const
Return the (long) name.
Definition gdalalgorithm_cpp.h:806
int GetMaxCharCount() const
Return the maximum number of characters (for arguments of type GAAT_STRING and GAAT_STRING_LIST)
Definition gdalalgorithm_cpp.h:897
const std::map< std::string, std::vector< std::string > > GetMetadata() const
Get user-defined metadata.
Definition gdalalgorithm_cpp.h:1085
GDALAlgorithmArgDecl & AddDirectDependency(const std::string &otherArgName)
Adds a direct dependency on another argument, meaning that if this argument is specified,...
Definition gdalalgorithm_cpp.h:753
GDALAlgorithmArgDecl & SetMinValueExcluded(double min)
Set the minimum (excluded) value allowed.
Definition gdalalgorithm_cpp.h:608
GDALAlgorithmArgDecl & SetRemoveSQLCommentsEnabled()
Sets that SQL comments must be removed from a (string) argument.
Definition gdalalgorithm_cpp.h:781
Argument of an algorithm.
Definition gdalalgorithm_cpp.h:1270
bool IsRemoveSQLCommentsEnabled() const
Alias for GDALAlgorithmArgDecl::IsRemoveSQLCommentsEnabled()
Definition gdalalgorithm_cpp.h:1507
T & Get()
Return the value of the argument, which is by decreasing order of priority:
Definition gdalalgorithm_cpp.h:1602
const std::string & GetMutualDependencyGroup() const
Alias for GDALAlgorithmArgDecl::GetMutualDependencyGroup()
Definition gdalalgorithm_cpp.h:1519
const std::vector< std::string > & GetAliases() const
Alias for GDALAlgorithmArgDecl::GetAliases()
Definition gdalalgorithm_cpp.h:1321
bool IsExplicitlySet() const
Return whether the argument value has been explicitly set with Set()
Definition gdalalgorithm_cpp.h:1452
int GetMinCount() const
Alias for GDALAlgorithmArgDecl::GetMinCount()
Definition gdalalgorithm_cpp.h:1363
GDALAlgorithmArg & operator=(const std::string &value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1760
const std::string & GetCategory() const
Alias for GDALAlgorithmArgDecl::GetCategory()
Definition gdalalgorithm_cpp.h:1351
bool IsInput() const
Alias for GDALAlgorithmArgDecl::IsInput()
Definition gdalalgorithm_cpp.h:1489
int GetMinCharCount() const
Alias for GDALAlgorithmArgDecl::GetMinCharCount()
Definition gdalalgorithm_cpp.h:1440
const T & Get() const
Return the value of the argument, which is by decreasing order of priority:
Definition gdalalgorithm_cpp.h:1623
bool IsRequired() const
Alias for GDALAlgorithmArgDecl::IsRequired()
Definition gdalalgorithm_cpp.h:1357
GDALAlgorithmArg & operator=(int value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1746
const std::string & GetName() const
Alias for GDALAlgorithmArgDecl::GetName()
Definition gdalalgorithm_cpp.h:1309
int GetDatasetInputFlags() const
Alias for GDALAlgorithmArgDecl::GetDatasetInputFlags()
Definition gdalalgorithm_cpp.h:1569
int GetMaxCount() const
Alias for GDALAlgorithmArgDecl::GetMaxCount()
Definition gdalalgorithm_cpp.h:1369
bool IsReadFromFileAtSyntaxAllowed() const
Alias for GDALAlgorithmArgDecl::IsReadFromFileAtSyntaxAllowed()
Definition gdalalgorithm_cpp.h:1501
const std::string & GetMetaVar() const
Alias for GDALAlgorithmArgDecl::GetMetaVar()
Definition gdalalgorithm_cpp.h:1339
int GetDatasetOutputFlags() const
Alias for GDALAlgorithmArgDecl::GetDatasetOutputFlags()
Definition gdalalgorithm_cpp.h:1575
GDALAlgorithmArg & operator=(const std::vector< int > &value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1788
const std::map< std::string, std::vector< std::string > > GetMetadata() const
Alias for GDALAlgorithmArgDecl::GetMetadata()
Definition gdalalgorithm_cpp.h:1532
const std::vector< std::string > & GetHiddenChoices() const
Alias for GDALAlgorithmArgDecl::GetHiddenChoices()
Definition gdalalgorithm_cpp.h:1411
const std::string & GetShortName() const
Alias for GDALAlgorithmArgDecl::GetShortName()
Definition gdalalgorithm_cpp.h:1315
GDALAlgorithmArg & operator=(const OGRSpatialReference &value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1781
const std::string & GetDescription() const
Alias for GDALAlgorithmArgDecl::GetDescription()
Definition gdalalgorithm_cpp.h:1333
GDALAlgorithmArg & operator=(const char *value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1767
const std::vector< std::string > & GetDirectDependencies() const
Alias for GDALAlgorithmArgDecl::GetDirectDependencies()
Definition gdalalgorithm_cpp.h:1525
const std::vector< std::string > * GetMetadataItem(const std::string &name) const
Alias for GDALAlgorithmArgDecl::GetMetadataItem()
Definition gdalalgorithm_cpp.h:1539
const std::vector< char > & GetShortNameAliases() const
Alias for GDALAlgorithmArgDecl::GetShortNameAliases()
Definition gdalalgorithm_cpp.h:1327
std::pair< double, bool > GetMaxValue() const
Alias for GDALAlgorithmArgDecl::GetMaxValue()
Definition gdalalgorithm_cpp.h:1434
bool IsAvailableInPipelineStep() const
Alias for GDALAlgorithmArgDecl::IsAvailableInPipelineStep()
Definition gdalalgorithm_cpp.h:1581
int GetMaxCharCount() const
Alias for GDALAlgorithmArgDecl::GetMaxCharCount()
Definition gdalalgorithm_cpp.h:1446
bool Set(GDALDataType dt)
Set the value for a GAAT_STRING argument from a GDALDataType It cannot be called several times for a ...
Definition gdalalgorithm_cpp.h:1657
const std::vector< std::string > & GetChoices() const
Alias for GDALAlgorithmArgDecl::GetChoices()
Definition gdalalgorithm_cpp.h:1405
void SetSkipIfAlreadySet(bool skip=true)
Advanced method used to make "gdal info" and "gdal raster|vector info" to avoid re-opening an already...
Definition gdalalgorithm_cpp.h:1828
bool GetPackedValuesAllowed() const
Alias for GDALAlgorithmArgDecl::GetPackedValuesAllowed()
Definition gdalalgorithm_cpp.h:1381
bool IsOnlyForCLI() const
Alias for GDALAlgorithmArgDecl::IsOnlyForCLI()
Definition gdalalgorithm_cpp.h:1476
bool IsOutput() const
Alias for GDALAlgorithmArgDecl::IsOutput()
Definition gdalalgorithm_cpp.h:1495
bool GetDuplicateValuesAllowed() const
Alias for GDALAlgorithmArgDecl::GetDuplicateValuesAllowed()
Definition gdalalgorithm_cpp.h:1393
virtual ~GDALAlgorithmArg()
Destructor.
bool HasDefaultValue() const
Alias for GDALAlgorithmArgDecl::HasDefaultValue()
Definition gdalalgorithm_cpp.h:1458
std::vector< std::string > GetAutoCompleteChoices(const std::string &currentValue) const
Return auto completion choices, if a auto completion function has been registered.
Definition gdalalgorithm_cpp.h:1420
bool IsHidden() const
Alias for GDALAlgorithmArgDecl::IsHidden()
Definition gdalalgorithm_cpp.h:1464
bool Set(const char *value)
Set the value for a GAAT_STRING argument.
Definition gdalalgorithm_cpp.h:1647
bool GetDisplayHintAboutRepetition() const
Alias for GDALAlgorithmArgDecl::GetDisplayHintAboutRepetition()
Definition gdalalgorithm_cpp.h:1375
GDALAlgorithmArgDecl m_decl
Argument declaration.
Definition gdalalgorithm_cpp.h:1860
GDALAlgorithmArg(const GDALAlgorithmArgDecl &decl, T *pValue)
Constructor.
Definition gdalalgorithm_cpp.h:1274
bool IsPositional() const
Alias for GDALAlgorithmArgDecl::IsPositional()
Definition gdalalgorithm_cpp.h:1399
GDALAlgorithmArg & operator=(const std::vector< double > &value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1795
bool AutoOpenDataset() const
Alias for GDALAlgorithmArgDecl::AutoOpenDataset()
Definition gdalalgorithm_cpp.h:1551
bool SkipIfAlreadySet() const
Advanced method used to make "gdal info" and "gdal raster|vector info" to avoid re-opening an already...
Definition gdalalgorithm_cpp.h:1835
const GDALAlgorithmArgDecl & GetDeclaration() const
Return the argument declaration.
Definition gdalalgorithm_cpp.h:1303
GDALAlgorithmArg & operator=(const std::vector< std::string > &value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1802
bool GetRepeatedArgAllowed() const
Alias for GDALAlgorithmArgDecl::GetRepeatedArgAllowed()
Definition gdalalgorithm_cpp.h:1387
GDALAlgorithmArg & operator=(double value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1753
std::pair< double, bool > GetMinValue() const
Alias for GDALAlgorithmArgDecl::GetMinValue()
Definition gdalalgorithm_cpp.h:1428
GDALAlgorithmArgType GetType() const
Alias for GDALAlgorithmArgDecl::GetType()
Definition gdalalgorithm_cpp.h:1345
GDALAlgorithmArg & operator=(GDALDataset *value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1809
const std::string & GetMutualExclusionGroup() const
Alias for GDALAlgorithmArgDecl::GetMutualExclusionGroup()
Definition gdalalgorithm_cpp.h:1513
bool IsHiddenForAPI() const
Alias for GDALAlgorithmArgDecl::IsHiddenForAPI()
Definition gdalalgorithm_cpp.h:1483
bool IsUserProvided() const
Alias for GDALAlgorithmArgDecl::IsUserProvided()
Definition gdalalgorithm_cpp.h:1557
GDALArgDatasetType GetDatasetType() const
Alias for GDALAlgorithmArgDecl::GetDatasetType()
Definition gdalalgorithm_cpp.h:1563
GDALAlgorithmArg & operator=(bool value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1739
bool IsHiddenForCLI() const
Alias for GDALAlgorithmArgDecl::IsHiddenForCLI()
Definition gdalalgorithm_cpp.h:1470
GDALAlgorithmArg & operator=(GDALDataType value)
Set the value of the argument.
Definition gdalalgorithm_cpp.h:1774
const T & GetDefault() const
Alias for GDALAlgorithmArgDecl::GetDefault()
Definition gdalalgorithm_cpp.h:1545
Algorithm information.
Definition gdalalgorithm_cpp.h:2326
std::function m_creationFunc
Creation function.
Definition gdalalgorithm_cpp.h:2334
std::string m_name
Algorithm (short) name.
Definition gdalalgorithm_cpp.h:2329
std::vector< std::string > m_aliases
Aliases.
Definition gdalalgorithm_cpp.h:2331
Registry of GDAL algorithms.
Definition gdalalgorithm_cpp.h:2316
bool empty() const
Returns true if there are no algorithms registered.
Definition gdalalgorithm_cpp.h:2396
std::unique_ptr< GDALAlgorithm > Instantiate(const std::string &first, V &&...rest)
Instantiate an algorithm by its path.
Definition gdalalgorithm_cpp.h:2381
const AlgInfo * GetInfo(const std::string &name) const
Get an algorithm by its name.
Definition gdalalgorithm_cpp.h:2389
bool Register()
Register the algorithm of type MyAlgorithm.
Definition gdalalgorithm_cpp.h:2343
GDAL algorithm.
Definition gdalalgorithm_cpp.h:2445
virtual void WarnIfDeprecated()
Method that an algorithm can implement to issue a warning message about its deprecation.
Definition gdalalgorithm_cpp.h:3199
bool SupportsStreamedOutput() const
Returns whether this algorithm supports a streamed output dataset.
Definition gdalalgorithm_cpp.h:2600
void AddValidationAction(std::function< bool()> f)
Register an action that is executed by the ValidateArguments() method.
Definition gdalalgorithm_cpp.h:3126
const std::string & GetHelpFullURL() const
Get the algorithm full URL, resolving relative URLs.
Definition gdalalgorithm_cpp.h:2478
void SetCallPath(const std::vector< std::string > &path)
Set the calling path to this algorithm.
Definition gdalalgorithm_cpp.h:2570
bool IsJSONUsageRequested() const
Whether the --json-usage flag has been specified.
Definition gdalalgorithm_cpp.h:2695
void SetReferencePathForRelativePaths(const std::string &referencePath)
Set the reference file paths used to interpret relative paths.
Definition gdalalgorithm_cpp.h:2588
bool m_progressBarRequested
Whether a progress bar is requested (value of --progress argument)
Definition gdalalgorithm_cpp.h:2793
bool IsHidden() const
Returns whether this algorithm is hidden.
Definition gdalalgorithm_cpp.h:2484
const std::string & GetLongDescription() const
Get the long algorithm description.
Definition gdalalgorithm_cpp.h:2464
std::vector< std::unique_ptr< GDALAlgorithmArg > > & GetArgs()
Return the potential arguments of the algorithm.
Definition gdalalgorithm_cpp.h:2511
void SetCalledFromCommandLine()
Set whether the algorithm is called from the command line.
Definition gdalalgorithm_cpp.h:2751
bool RegisterSubAlgorithm()
Register the sub-algorithm of type MyAlgorithm.
Definition gdalalgorithm_cpp.h:2834
const std::string & GetDescription() const
Get the algorithm description (a few sentences at most)
Definition gdalalgorithm_cpp.h:2458
ProcessGDALGOutputRet
Return value for ProcessGDALGOutput.
Definition gdalalgorithm_cpp.h:3147
bool IsCalledFromCommandLine() const
Return whether the algorithm is called from the command line.
Definition gdalalgorithm_cpp.h:2757
GDALAlgorithm & GetActualAlgorithm()
Return the actual algorithm that is going to be invoked, when the current algorithm has sub-algorithm...
Definition gdalalgorithm_cpp.h:2681
const GDALAlgorithmArg * GetArg(const std::string &osName, bool suggestionAllowed=false) const
Return an argument from its long name, short name or an alias.
Definition gdalalgorithm_cpp.h:2540
void AllowArbitraryLongNameArgs()
Allow arbitrary user arguments using long name syntax (–something)
Definition gdalalgorithm_cpp.h:2847
GDALAlgorithmArg & operator[](const std::string &osName)
Return an argument from its long name, short name or an alias.
Definition gdalalgorithm_cpp.h:2527
GDALAlgorithmArg * GetArg(const std::string &osName, bool suggestionAllowed=false)
Return an argument from its long name, short name or an alias.
Definition gdalalgorithm_cpp.h:2520
bool m_quiet
Whether a progress bar is disabled (value of --quiet argument)
Definition gdalalgorithm_cpp.h:2796
const std::string & GetHelpURL() const
Get the algorithm help URL.
Definition gdalalgorithm_cpp.h:2472
const std::vector< std::unique_ptr< GDALAlgorithmArg > > & GetArgs() const
Return the potential arguments of the algorithm.
Definition gdalalgorithm_cpp.h:2505
const std::string & GetName() const
Get the algorithm name.
Definition gdalalgorithm_cpp.h:2452
bool RegisterSubAlgorithm(const GDALAlgorithmRegistry::AlgInfo &info)
Register a sub-algoritm by its AlgInfo structure.
Definition gdalalgorithm_cpp.h:2841
void SetParseForAutoCompletion()
Set hint before calling ParseCommandLineArguments() that it must try to be be graceful when possible,...
Definition gdalalgorithm_cpp.h:2579
void SetExecutionForStreamedOutput()
Indicates that the algorithm must be run to generate a streamed output dataset.
Definition gdalalgorithm_cpp.h:2612
const GDALAlgorithmArg & operator[](const std::string &osName) const
Return an argument from its long name, short name or an alias.
Definition gdalalgorithm_cpp.h:2548
bool IsProgressBarRequested() const
Whether the --progress flag has been specified.
Definition gdalalgorithm_cpp.h:2701
const std::string & GetReferencePathForRelativePaths() const
Return the reference file paths used to interpret relative paths.
Definition gdalalgorithm_cpp.h:2594
const std::vector< std::string > & GetAliases() const
Return alias names (generally short) for the current algorithm.
Definition gdalalgorithm_cpp.h:2709
void SetDisplayInJSONUsage(bool b)
Set whether this algorithm should be reported in JSON usage.
Definition gdalalgorithm_cpp.h:3191
bool PropagateSpecialActionTo(GDALAlgorithm *target)
Used by the "gdal info" special algorithm when it first tries to run "gdal raster info",...
Definition gdalalgorithm_cpp.h:2729
bool IsHelpRequested() const
Whether the --help flag has been specified.
Definition gdalalgorithm_cpp.h:2689
Value for an argument that points to a GDALDataset.
Definition gdalalgorithm_cpp.h:163
GDALArgDatasetValue()=default
Default (empty) constructor.
const std::string & GetName() const
Get dataset name.
Definition gdalalgorithm_cpp.h:236
GDALDataset * BorrowDataset()
Borrow the GDALDataset* instance (may be null), leaving its reference counter unchanged.
Definition gdalalgorithm_cpp.h:218
GDALArgDatasetValue(const std::string &name)
Constructor by dataset name.
Definition gdalalgorithm_cpp.h:169
const GDALDataset * GetDatasetRef() const
Get a GDALDataset* instance (may be null).
Definition gdalalgorithm_cpp.h:210
GDALDataset * GetDatasetRef()
Get a GDALDataset* instance (may be null).
Definition gdalalgorithm_cpp.h:201
bool HasDatasetBeenOpenedByAlgorithm() const
Whether the dataset has been opened by the algorithm.
Definition gdalalgorithm_cpp.h:269
void SetOwnerArgument(GDALAlgorithmArg *arg)
Set the argument that owns us.
Definition gdalalgorithm_cpp.h:278
void SetDatasetOpenedByAlgorithm()
Set that the dataset has been opened by the algorithm.
Definition gdalalgorithm_cpp.h:263
bool IsNameSet() const
Return whether a dataset name has been set.
Definition gdalalgorithm_cpp.h:242
void BorrowDatasetFrom(GDALArgDatasetValue &other)
Borrow the GDALDataset* instance from another GDALArgDatasetValue, leaving its reference counter unch...
Definition gdalalgorithm_cpp.h:228
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:77
Global registry of GDAL algorithms.
Definition gdalalgorithm_cpp.h:3345
std::function< std::unique_ptr< GDALAlgorithm >()> InstantiateFunc
Instantiation function.
Definition gdalalgorithm_cpp.h:3354
Technical class used by GDALAlgorithm when constructing argument declarations.
Definition gdalalgorithm_cpp.h:1918
GDALInConstructionAlgorithmArg & SetMutualDependencyGroup(const std::string &group)
Alias for GDALAlgorithmArgDecl::SetMutualDependencyGroup()
Definition gdalalgorithm_cpp.h:2207
GDALInConstructionAlgorithmArg & SetDatasetInputFlags(int flags)
Alias for GDALAlgorithmArgDecl::SetDatasetInputFlags()
Definition gdalalgorithm_cpp.h:2239
GDALInConstructionAlgorithmArg & SetDefault(const T &value)
Alias for GDALAlgorithmArgDecl::SetDefault()
Definition gdalalgorithm_cpp.h:1969
GDALInConstructionAlgorithmArg & AddAction(std::function< void()> f)
Register an action that is executed, once and exactly once, if the argument is explicitly set,...
Definition gdalalgorithm_cpp.h:2255
GDALInConstructionAlgorithmArg & SetHiddenChoices(T &&first, U &&...rest)
Alias for GDALAlgorithmArgDecl::SetHiddenChoices()
Definition gdalalgorithm_cpp.h:2092
GDALInConstructionAlgorithmArg & SetMaxValueIncluded(double max)
Alias for GDALAlgorithmArgDecl::SetMaxValueIncluded()
Definition gdalalgorithm_cpp.h:2114
GDALInConstructionAlgorithmArg & SetHidden()
Alias for GDALAlgorithmArgDecl::SetHidden()
Definition gdalalgorithm_cpp.h:2142
GDALInConstructionAlgorithmArg & AddDirectDependency(const GDALAlgorithmArg &otherArg)
Add a direct (not mutual) dependency from an argument.
Definition gdalalgorithm_cpp.h:2215
GDALInConstructionAlgorithmArg & SetDatasetOutputFlags(int flags)
Alias for GDALAlgorithmArgDecl::SetDatasetOutputFlags()
Definition gdalalgorithm_cpp.h:2246
GDALInConstructionAlgorithmArg & SetDuplicateValuesAllowed(bool allowed)
Alias for GDALAlgorithmArgDecl::SetDuplicateValuesAllowed()
Definition gdalalgorithm_cpp.h:2065
GDALInConstructionAlgorithmArg & SetReadFromFileAtSyntaxAllowed()
Alias for GDALAlgorithmArgDecl::SetReadFromFileAtSyntaxAllowed()
Definition gdalalgorithm_cpp.h:2177
~GDALInConstructionAlgorithmArg() override
Destructor.
GDALInConstructionAlgorithmArg & SetMinCount(int count)
Alias for GDALAlgorithmArgDecl::SetMinCount()
Definition gdalalgorithm_cpp.h:2029
GDALInConstructionAlgorithmArg & SetIsOutput(bool isOutput=true)
Alias for GDALAlgorithmArgDecl::SetIsOutput()
Definition gdalalgorithm_cpp.h:2170
GDALInConstructionAlgorithmArg & SetRemoveSQLCommentsEnabled()
Alias for GDALAlgorithmArgDecl::SetRemoveSQLCommentsEnabled()
Definition gdalalgorithm_cpp.h:2184
GDALInConstructionAlgorithmArg & SetDefault(const char *value)
Alias for GDALAlgorithmArgDecl::SetDefault()
Definition gdalalgorithm_cpp.h:2023
GDALInConstructionAlgorithmArg & SetMaxCount(int count)
Alias for GDALAlgorithmArgDecl::SetMaxCount()
Definition gdalalgorithm_cpp.h:2036
GDALInConstructionAlgorithmArg & SetMaxValueExcluded(double max)
Alias for GDALAlgorithmArgDecl::SetMaxValueExcluded()
Definition gdalalgorithm_cpp.h:2121
GDALInConstructionAlgorithmArg & SetHiddenForAPI(bool hiddenForAPI=true)
Alias for GDALAlgorithmArgDecl::SetHiddenForAPI()
Definition gdalalgorithm_cpp.h:2156
GDALInConstructionAlgorithmArg & SetDisplayHintAboutRepetition(bool displayHint)
Alias for GDALAlgorithmArgDecl::SetDisplayHintAboutRepetition()
Definition gdalalgorithm_cpp.h:2044
GDALInConstructionAlgorithmArg & SetAvailableInPipelineStep(bool available)
Alias for GDALAlgorithmArgDecl::SetAvailableInPipelineStep()
Definition gdalalgorithm_cpp.h:2295
GDALInConstructionAlgorithmArg & SetAutoOpenDataset(bool autoOpen)
Alias for GDALAlgorithmArgDecl::SetAutoOpenDataset()
Definition gdalalgorithm_cpp.h:2191
GDALInConstructionAlgorithmArg & SetDatasetType(GDALArgDatasetType datasetType)
Alias for GDALAlgorithmArgDecl::SetDatasetType()
Definition gdalalgorithm_cpp.h:2232
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.
Definition gdalalgorithm_cpp.h:2276
GDALInConstructionAlgorithmArg & SetPackedValuesAllowed(bool allowed)
Alias for GDALAlgorithmArgDecl::SetPackedValuesAllowed()
Definition gdalalgorithm_cpp.h:2051
GDALInConstructionAlgorithmArg & SetUserProvided()
Alias for GDALAlgorithmArgDecl::SetUserProvided()
Definition gdalalgorithm_cpp.h:2302
GDALInConstructionAlgorithmArg & SetChoices(const std::vector< std::string > &choices)
Alias for GDALAlgorithmArgDecl::SetChoices()
Definition gdalalgorithm_cpp.h:2084
GDALInConstructionAlgorithmArg & SetMaxCharCount(int count)
Alias for GDALAlgorithmArgDecl::SetMaxCharCount()
Definition gdalalgorithm_cpp.h:2135
GDALInConstructionAlgorithmArg & SetMinCharCount(int count)
Alias for GDALAlgorithmArgDecl::SetMinCharCount()
Definition gdalalgorithm_cpp.h:2128
GDALInConstructionAlgorithmArg & SetHiddenForCLI(bool hiddenForCLI=true)
Alias for GDALAlgorithmArgDecl::SetHiddenForCLI()
Definition gdalalgorithm_cpp.h:2149
GDALInConstructionAlgorithmArg & AddMetadataItem(const std::string &name, const std::vector< std::string > &values)
Alias for GDALAlgorithmArgDecl::AddMetadataItem()
Definition gdalalgorithm_cpp.h:2223
GDALInConstructionAlgorithmArg & SetMutualExclusionGroup(const std::string &group)
Alias for GDALAlgorithmArgDecl::SetMutualExclusionGroup()
Definition gdalalgorithm_cpp.h:2199
GDALInConstructionAlgorithmArg & SetMinValueIncluded(double min)
Alias for GDALAlgorithmArgDecl::SetMinValueIncluded()
Definition gdalalgorithm_cpp.h:2100
GDALInConstructionAlgorithmArg & SetChoices(T &&first, U &&...rest)
Alias for GDALAlgorithmArgDecl::SetChoices()
Definition gdalalgorithm_cpp.h:2076
GDALInConstructionAlgorithmArg & SetIsInput(bool isInput=true)
Alias for GDALAlgorithmArgDecl::SetIsInput()
Definition gdalalgorithm_cpp.h:2163
GDALInConstructionAlgorithmArg & SetRequired()
Alias for GDALAlgorithmArgDecl::SetRequired()
Definition gdalalgorithm_cpp.h:1947
GDALInConstructionAlgorithmArg & SetMetaVar(const std::string &metaVar)
Alias for GDALAlgorithmArgDecl::SetMetaVar()
Definition gdalalgorithm_cpp.h:1954
GDALInConstructionAlgorithmArg(GDALAlgorithm *owner, const GDALAlgorithmArgDecl &decl, T *pValue)
Constructor.
Definition gdalalgorithm_cpp.h:1924
GDALInConstructionAlgorithmArg & SetRepeatedArgAllowed(bool allowed)
Alias for GDALAlgorithmArgDecl::SetRepeatedArgAllowed()
Definition gdalalgorithm_cpp.h:2058
GDALInConstructionAlgorithmArg & SetMinValueExcluded(double min)
Alias for GDALAlgorithmArgDecl::SetMinValueExcluded()
Definition gdalalgorithm_cpp.h:2107
GDALInConstructionAlgorithmArg & SetCategory(const std::string &category)
Alias for GDALAlgorithmArgDecl::SetCategory()
Definition gdalalgorithm_cpp.h:1961
GDALInConstructionAlgorithmArg & AddValidationAction(std::function< bool()> f)
Register an action that is executed, once and exactly once, if the argument is explicitly set,...
Definition gdalalgorithm_cpp.h:2267
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:72
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
CPL error handling services.
#define CPLAssert(expr)
Assert on an expression.
Definition cpl_error.h:353
CPLErr
Error category / error level.
Definition cpl_error.h:45
@ CE_Failure
Error that prevents the current operation to succeed.
Definition cpl_error.h:60
#define CPLE_AppDefined
Application defined error.
Definition cpl_error.h:108
int CPLErrorNum
Error number.
Definition cpl_error.h:103
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition cpl_port.h:1009
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1101
GDALDataType
Definition gdal.h:48
#define GDAL_OF_RASTER
Allow raster drivers to be used.
Definition gdal.h:1125
#define GDAL_OF_VECTOR
Allow vector drivers to be used.
Definition gdal.h:1130
const char * GDALGetDataTypeName(GDALDataType)
Get name of data type.
Definition gdal_misc.cpp:715
#define GDAL_OF_MULTIDIM_RASTER
Allow multidimensional raster drivers to be used.
Definition gdal.h:1141
void * OGRLayerH
Opaque type for a layer (OGRLayer)
Definition gdal_fwd.h:157
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:817
OGRFieldType
List of feature field types.
Definition ogr_core.h:790
Simple feature classes.
Usage options.
Definition gdalalgorithm_cpp.h:2649
bool isPipelineStep
Whether this is a pipeline step.
Definition gdalalgorithm_cpp.h:2651
size_t maxOptLen
Maximum width of the names of the options.
Definition gdalalgorithm_cpp.h:2653
bool isPipelineMain
Whether this is a pipeline main.
Definition gdalalgorithm_cpp.h:2655