GDAL
gdalalg_vector_output_abstract.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: Class to abstract outputting to a vector layer
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 GDALALG_VECTOR_OUTPUT_ABSTRACT_INCLUDED
14#define GDALALG_VECTOR_OUTPUT_ABSTRACT_INCLUDED
15
16#include "gdalalgorithm.h"
17#include "ogrsf_frmts.h"
18
20
21/************************************************************************/
22/* GDALVectorOutputAbstractAlgorithm */
23/************************************************************************/
24
25class CPL_DLL
26 GDALVectorOutputAbstractAlgorithm /* non-final*/ : public GDALAlgorithm
27{
28 protected:
29 GDALVectorOutputAbstractAlgorithm(const std::string &name,
30 const std::string &description,
31 const std::string &helpURL)
32 : GDALAlgorithm(name, description, helpURL)
33 {
34 }
35
36 ~GDALVectorOutputAbstractAlgorithm() override;
37
38 void AddAllOutputArgs();
39
40 struct SetupOutputDatasetRet
41 {
42 std::unique_ptr<GDALDataset> newDS{};
43 GDALDataset *outDS =
44 nullptr; // either newDS.get() or m_outputDataset.GetDatasetRef()
45 OGRLayer *layer = nullptr;
46
47 SetupOutputDatasetRet() = default;
48 SetupOutputDatasetRet(SetupOutputDatasetRet &&) = default;
49 SetupOutputDatasetRet &operator=(SetupOutputDatasetRet &&) = default;
50
51 CPL_DISALLOW_COPY_ASSIGN(SetupOutputDatasetRet)
52 };
53
54 SetupOutputDatasetRet SetupOutputDataset();
55 bool SetDefaultOutputLayerNameIfNeeded(GDALDataset *poOutDS);
56
57 std::string m_outputFormat{};
58 GDALArgDatasetValue m_outputDataset{};
59 std::vector<std::string> m_creationOptions{};
60 std::vector<std::string> m_layerCreationOptions{};
61 std::string m_outputLayerName{};
62 bool m_overwrite = false;
63 bool m_update = false;
64 bool m_overwriteLayer = false;
65 bool m_appendLayer = false;
66};
67
69
70#endif
GDAL algorithm.
Definition gdalalgorithm_cpp.h:2261
#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:936
Classes related to registration of format support, and opening datasets.