GDAL

gdalalgorithm_c.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_C_INCLUDED
14#define GDAL_ALGORITHM_C_INCLUDED
15
16#include "cpl_port.h"
17#include "cpl_progress.h"
18
19#include "gdal.h"
20
21/************************************************************************/
22/************************************************************************/
23/* GDAL Algorithm C API */
24/************************************************************************/
25/************************************************************************/
26
27 CPL_C_START
28
30 typedef enum
31{
33 GAAT_BOOLEAN,
35 GAAT_STRING,
37 GAAT_INTEGER,
39 GAAT_REAL,
41 GAAT_DATASET,
43 GAAT_STRING_LIST,
45 GAAT_INTEGER_LIST,
47 GAAT_REAL_LIST,
49 GAAT_DATASET_LIST,
50} GDALAlgorithmArgType;
51
53 bool CPL_DLL GDALAlgorithmArgTypeIsList(GDALAlgorithmArgType type);
54
56 const char CPL_DLL *GDALAlgorithmArgTypeName(GDALAlgorithmArgType type);
57
59 typedef struct GDALArgDatasetValueHS *GDALArgDatasetValueH;
60
62 typedef struct GDALAlgorithmArgHS *GDALAlgorithmArgH;
63
65 typedef struct GDALAlgorithmHS *GDALAlgorithmH;
66
68 typedef struct GDALAlgorithmRegistryHS *GDALAlgorithmRegistryH;
69
70/************************************************************************/
71/* GDALAlgorithmRegistryH API */
72/************************************************************************/
73
74GDALAlgorithmRegistryH CPL_DLL GDALGetGlobalAlgorithmRegistry(void);
75
76 void CPL_DLL GDALAlgorithmRegistryRelease(GDALAlgorithmRegistryH);
77
78 char CPL_DLL **GDALAlgorithmRegistryGetAlgNames(GDALAlgorithmRegistryH);
79
80GDALAlgorithmH CPL_DLL GDALAlgorithmRegistryInstantiateAlg(
81 GDALAlgorithmRegistryH, const char *pszAlgName);
82
83GDALAlgorithmH CPL_DLL GDALAlgorithmRegistryInstantiateAlgFromPath(
84 GDALAlgorithmRegistryH, const char *const *papszAlgPath);
85
86/************************************************************************/
87/* GDALAlgorithmH API */
88/************************************************************************/
89
90 void CPL_DLL GDALAlgorithmRelease(GDALAlgorithmH);
91
92 const char CPL_DLL *GDALAlgorithmGetName(GDALAlgorithmH);
93
94 const char CPL_DLL *GDALAlgorithmGetDescription(GDALAlgorithmH);
95
96 const char CPL_DLL *GDALAlgorithmGetLongDescription(GDALAlgorithmH);
97
98 const char CPL_DLL *GDALAlgorithmGetHelpFullURL(GDALAlgorithmH);
99
100 bool CPL_DLL GDALAlgorithmHasSubAlgorithms(GDALAlgorithmH);
101
102 char CPL_DLL **GDALAlgorithmGetSubAlgorithmNames(GDALAlgorithmH);
103
104GDALAlgorithmH CPL_DLL
105GDALAlgorithmInstantiateSubAlgorithm(GDALAlgorithmH, const char *pszSubAlgName);
106
107 bool CPL_DLL GDALAlgorithmParseCommandLineArguments(GDALAlgorithmH,
108 CSLConstList papszArgs);
109
110GDALAlgorithmH CPL_DLL GDALAlgorithmGetActualAlgorithm(GDALAlgorithmH);
111
112 bool CPL_DLL GDALAlgorithmRun(GDALAlgorithmH, GDALProgressFunc pfnProgress,
113 void *pProgressData);
114
115 bool CPL_DLL GDALAlgorithmFinalize(GDALAlgorithmH);
116
117 char CPL_DLL *GDALAlgorithmGetUsageAsJSON(GDALAlgorithmH);
118
119 char CPL_DLL **GDALAlgorithmGetArgNames(GDALAlgorithmH);
120
121GDALAlgorithmArgH CPL_DLL GDALAlgorithmGetArg(GDALAlgorithmH,
122 const char *pszArgName);
123
124GDALAlgorithmArgH CPL_DLL GDALAlgorithmGetArgNonConst(GDALAlgorithmH,
125 const char *pszArgName);
126
127/************************************************************************/
128/* GDALAlgorithmArgH API */
129/************************************************************************/
130
131 void CPL_DLL GDALAlgorithmArgRelease(GDALAlgorithmArgH);
132
133 const char CPL_DLL *GDALAlgorithmArgGetName(GDALAlgorithmArgH);
134
135GDALAlgorithmArgType CPL_DLL GDALAlgorithmArgGetType(GDALAlgorithmArgH);
136
137 const char CPL_DLL *GDALAlgorithmArgGetDescription(GDALAlgorithmArgH);
138
139 const char CPL_DLL *GDALAlgorithmArgGetShortName(GDALAlgorithmArgH);
140
141 char CPL_DLL **GDALAlgorithmArgGetAliases(GDALAlgorithmArgH);
142
143 const char CPL_DLL *GDALAlgorithmArgGetMetaVar(GDALAlgorithmArgH);
144
145 const char CPL_DLL *GDALAlgorithmArgGetCategory(GDALAlgorithmArgH);
146
147 bool CPL_DLL GDALAlgorithmArgIsPositional(GDALAlgorithmArgH);
148
149 bool CPL_DLL GDALAlgorithmArgIsRequired(GDALAlgorithmArgH);
150
151 int CPL_DLL GDALAlgorithmArgGetMinCount(GDALAlgorithmArgH);
152
153 int CPL_DLL GDALAlgorithmArgGetMaxCount(GDALAlgorithmArgH);
154
155 bool CPL_DLL GDALAlgorithmArgGetPackedValuesAllowed(GDALAlgorithmArgH);
156
157 bool CPL_DLL GDALAlgorithmArgGetRepeatedArgAllowed(GDALAlgorithmArgH);
158
159 char CPL_DLL **GDALAlgorithmArgGetChoices(GDALAlgorithmArgH);
160
161 char CPL_DLL **GDALAlgorithmArgGetMetadataItem(GDALAlgorithmArgH, const char *);
162
163 bool CPL_DLL GDALAlgorithmArgIsExplicitlySet(GDALAlgorithmArgH);
164
165 bool CPL_DLL GDALAlgorithmArgHasDefaultValue(GDALAlgorithmArgH);
166
167 bool CPL_DLL GDALAlgorithmArgGetDefaultAsBoolean(GDALAlgorithmArgH);
168
169 const char CPL_DLL *GDALAlgorithmArgGetDefaultAsString(GDALAlgorithmArgH);
170
171 int CPL_DLL GDALAlgorithmArgGetDefaultAsInteger(GDALAlgorithmArgH);
172
173 double CPL_DLL GDALAlgorithmArgGetDefaultAsDouble(GDALAlgorithmArgH);
174
175 char CPL_DLL **GDALAlgorithmArgGetDefaultAsStringList(GDALAlgorithmArgH);
176
177 const int CPL_DLL *GDALAlgorithmArgGetDefaultAsIntegerList(GDALAlgorithmArgH,
178 size_t *pnCount);
179
180 const double CPL_DLL *GDALAlgorithmArgGetDefaultAsDoubleList(GDALAlgorithmArgH,
181 size_t *pnCount);
182
183 bool CPL_DLL GDALAlgorithmArgIsHidden(GDALAlgorithmArgH);
184
185 bool CPL_DLL GDALAlgorithmArgIsHiddenForCLI(GDALAlgorithmArgH);
186
187 bool CPL_DLL GDALAlgorithmArgIsHiddenForAPI(GDALAlgorithmArgH);
188
189#ifndef DOXYGEN_SKIP
190 bool CPL_DLL GDALAlgorithmArgIsOnlyForCLI(GDALAlgorithmArgH)
191 CPL_WARN_DEPRECATED("Use GDALAlgorithmArgIsHiddenForAPI() instead");
192#endif
193
194 bool CPL_DLL GDALAlgorithmArgIsInput(GDALAlgorithmArgH);
195
196 bool CPL_DLL GDALAlgorithmArgIsOutput(GDALAlgorithmArgH);
197
198 const char CPL_DLL *GDALAlgorithmArgGetMutualExclusionGroup(GDALAlgorithmArgH);
199
200 bool CPL_DLL GDALAlgorithmArgGetAsBoolean(GDALAlgorithmArgH);
201
202 const char CPL_DLL *GDALAlgorithmArgGetAsString(GDALAlgorithmArgH);
203
204GDALArgDatasetValueH
205 CPL_DLL GDALAlgorithmArgGetAsDatasetValue(GDALAlgorithmArgH);
206
207 int CPL_DLL GDALAlgorithmArgGetAsInteger(GDALAlgorithmArgH);
208
209 double CPL_DLL GDALAlgorithmArgGetAsDouble(GDALAlgorithmArgH);
210
211 char CPL_DLL **GDALAlgorithmArgGetAsStringList(GDALAlgorithmArgH);
212
213 const int CPL_DLL *GDALAlgorithmArgGetAsIntegerList(GDALAlgorithmArgH,
214 size_t *pnCount);
215
216 const double CPL_DLL *GDALAlgorithmArgGetAsDoubleList(GDALAlgorithmArgH,
217 size_t *pnCount);
218
219 bool CPL_DLL GDALAlgorithmArgSetAsBoolean(GDALAlgorithmArgH, bool);
220
221 bool CPL_DLL GDALAlgorithmArgSetAsString(GDALAlgorithmArgH, const char *);
222
223 bool CPL_DLL GDALAlgorithmArgSetAsDatasetValue(GDALAlgorithmArgH hArg,
224 GDALArgDatasetValueH value);
225
226 bool CPL_DLL GDALAlgorithmArgSetDataset(GDALAlgorithmArgH hArg, GDALDatasetH);
227
228 bool CPL_DLL GDALAlgorithmArgSetDatasets(GDALAlgorithmArgH hArg, size_t nCount,
229 GDALDatasetH *);
230
231 bool CPL_DLL GDALAlgorithmArgSetDatasetNames(GDALAlgorithmArgH hArg,
232 CSLConstList);
233
234 bool CPL_DLL GDALAlgorithmArgSetAsInteger(GDALAlgorithmArgH, int);
235
236 bool CPL_DLL GDALAlgorithmArgSetAsDouble(GDALAlgorithmArgH, double);
237
238 bool CPL_DLL GDALAlgorithmArgSetAsStringList(GDALAlgorithmArgH, CSLConstList);
239
240 bool CPL_DLL GDALAlgorithmArgSetAsIntegerList(GDALAlgorithmArgH, size_t nCount,
241 const int *pnValues);
242
243 bool CPL_DLL GDALAlgorithmArgSetAsDoubleList(GDALAlgorithmArgH, size_t nCount,
244 const double *pnValues);
245
249 typedef int GDALArgDatasetType;
250
251GDALArgDatasetType CPL_DLL GDALAlgorithmArgGetDatasetType(GDALAlgorithmArgH);
252
254#define GADV_NAME (1 << 0)
256#define GADV_OBJECT (1 << 1)
257
258 int CPL_DLL GDALAlgorithmArgGetDatasetInputFlags(GDALAlgorithmArgH);
259
260 int CPL_DLL GDALAlgorithmArgGetDatasetOutputFlags(GDALAlgorithmArgH);
261
262/************************************************************************/
263/* GDALArgDatasetValueH API */
264/************************************************************************/
265
266GDALArgDatasetValueH CPL_DLL GDALArgDatasetValueCreate(void);
267
268 void CPL_DLL GDALArgDatasetValueRelease(GDALArgDatasetValueH);
269
270 const char CPL_DLL *GDALArgDatasetValueGetName(GDALArgDatasetValueH);
271
272 GDALDatasetH CPL_DLL GDALArgDatasetValueGetDatasetRef(GDALArgDatasetValueH);
273
274 GDALDatasetH
275 CPL_DLL GDALArgDatasetValueGetDatasetIncreaseRefCount(GDALArgDatasetValueH);
276
277 void CPL_DLL GDALArgDatasetValueSetName(GDALArgDatasetValueH, const char *);
278
279 void CPL_DLL GDALArgDatasetValueSetDataset(GDALArgDatasetValueH, GDALDatasetH);
280
281 CPL_C_END
282
283#endif // GDAL_ALGORITHM_C_INCLUDED
cpl_port.h
Core portability definitions for CPL.
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
gdal.h
Public (C callable) GDAL entry points.
GDALDatasetH
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition gdal_fwd.h:42