Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "sql" step of "vector pipeline" 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_SQL_INCLUDED 14 : #define GDALALG_VECTOR_SQL_INCLUDED 15 : 16 : #include "gdalalg_vector_pipeline.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALVectorSQLAlgorithm */ 22 : /************************************************************************/ 23 : 24 : class GDALVectorSQLAlgorithm /* non final */ 25 : : public GDALVectorPipelineStepAlgorithm 26 : { 27 : public: 28 : static constexpr const char *NAME = "sql"; 29 : static constexpr const char *DESCRIPTION = 30 : "Apply SQL statement(s) to a dataset."; 31 : static constexpr const char *HELP_URL = "/programs/gdal_vector_sql.html"; 32 : 33 : explicit GDALVectorSQLAlgorithm(bool standaloneStep = false); 34 : 35 : private: 36 : static ConstructorOptions GetConstructorOptions(bool standaloneStep); 37 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 38 : 39 : std::vector<std::string> m_sql{}; 40 : std::vector<std::string> m_outputLayer{}; 41 : std::string m_dialect{}; 42 : bool m_quiet = false; 43 : }; 44 : 45 : /************************************************************************/ 46 : /* GDALVectorSQLAlgorithmStandalone */ 47 : /************************************************************************/ 48 : 49 28 : class GDALVectorSQLAlgorithmStandalone final : public GDALVectorSQLAlgorithm 50 : { 51 : public: 52 14 : GDALVectorSQLAlgorithmStandalone() 53 14 : : GDALVectorSQLAlgorithm(/* standaloneStep = */ true) 54 : { 55 14 : } 56 : 57 : ~GDALVectorSQLAlgorithmStandalone() override; 58 : }; 59 : 60 : //! @endcond 61 : 62 : #endif /* GDALALG_VECTOR_SQL_INCLUDED */