Line data Source code
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 35 : GDALVectorOutputAbstractAlgorithm(const std::string &name, 30 : const std::string &description, 31 : const std::string &helpURL) 32 35 : : GDALAlgorithm(name, description, helpURL) 33 : { 34 35 : } 35 : 36 : void AddAllOutputArgs(); 37 : 38 : struct SetupOutputDatasetRet 39 : { 40 : std::unique_ptr<GDALDataset> newDS{}; 41 : GDALDataset *outDS = 42 : nullptr; // either newDS.get() or m_outputDataset.GetDatasetRef() 43 : OGRLayer *layer = nullptr; 44 : 45 18 : SetupOutputDatasetRet() = default; 46 : SetupOutputDatasetRet(SetupOutputDatasetRet &&) = default; 47 : SetupOutputDatasetRet &operator=(SetupOutputDatasetRet &&) = default; 48 : 49 : CPL_DISALLOW_COPY_ASSIGN(SetupOutputDatasetRet) 50 : }; 51 : 52 : SetupOutputDatasetRet SetupOutputDataset(); 53 : bool SetDefaultOutputLayerNameIfNeeded(GDALDataset *poOutDS); 54 : 55 : std::string m_outputFormat{}; 56 : GDALArgDatasetValue m_outputDataset{}; 57 : std::vector<std::string> m_creationOptions{}; 58 : std::vector<std::string> m_layerCreationOptions{}; 59 : std::string m_outputLayerName{}; 60 : bool m_overwrite = false; 61 : bool m_update = false; 62 : bool m_overwriteLayer = false; 63 : bool m_appendLayer = false; 64 : }; 65 : 66 : //! @endcond 67 : 68 : #endif