Coverage Report

Created: 2025-08-11 09:23

/src/gdal/apps/gdalalg_vector_output_abstract.h
Line
Count
Source (jump to first uncovered line)
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
19
//! @cond Doxygen_Suppress
20
21
/************************************************************************/
22
/*                  GDALVectorOutputAbstractAlgorithm                   */
23
/************************************************************************/
24
25
class 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
1
        : GDALAlgorithm(name, description, helpURL)
33
1
    {
34
1
    }
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
0
        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
68
//! @endcond
69
70
#endif