Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "dataset identify" subcommand 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_MANAGE_IDENTIFY_INCLUDED 14 : #define GDALALG_MANAGE_IDENTIFY_INCLUDED 15 : 16 : #include "gdalalgorithm.h" 17 : 18 : #include "cpl_json_streaming_writer.h" 19 : #include "cpl_vsi_virtual.h" 20 : 21 : //! @cond Doxygen_Suppress 22 : 23 : class OGRLayer; 24 : 25 : /************************************************************************/ 26 : /* GDALDatasetIdentifyAlgorithm */ 27 : /************************************************************************/ 28 : 29 54 : class GDALDatasetIdentifyAlgorithm final : public GDALAlgorithm 30 : { 31 : public: 32 : static constexpr const char *NAME = "identify"; 33 : static constexpr const char *DESCRIPTION = 34 : "Identify driver opening dataset(s)."; 35 : static constexpr const char *HELP_URL = 36 : "/programs/gdal_dataset_identify.html"; 37 : 38 : GDALDatasetIdentifyAlgorithm(); 39 : ~GDALDatasetIdentifyAlgorithm() override; 40 : 41 : private: 42 : std::vector<std::string> m_filename{}; 43 : std::string m_format{}; 44 : std::vector<std::string> m_creationOptions{}; 45 : std::vector<std::string> m_layerCreationOptions{}; 46 : GDALArgDatasetValue m_outputDataset{}; 47 : std::string m_outputLayerName{}; 48 : bool m_overwrite = false; 49 : std::string m_output{}; 50 : bool m_recursive = false; 51 : bool m_forceRecursive = false; 52 : bool m_reportFailures = false; 53 : bool m_detailed = false; 54 : bool m_stdout = false; 55 : 56 : CPLJSonStreamingWriter m_oWriter; 57 : VSIVirtualHandleUniquePtr m_fpOut{}; 58 : std::unique_ptr<GDALDataset> m_poOutDS{}; 59 : OGRLayer *m_poLayer = nullptr; 60 : 61 : bool RunImpl(GDALProgressFunc, void *) override; 62 : void Print(const char *str); 63 : bool Process(const char *pszTarget, CSLConstList papszSiblingList, 64 : GDALProgressFunc pfnProgress, void *pProgressData); 65 : static void JSONPrint(const char *pszTxt, void *pUserData); 66 : 67 : GDALDatasetIdentifyAlgorithm(const GDALDatasetIdentifyAlgorithm &) = delete; 68 : GDALDatasetIdentifyAlgorithm & 69 : operator=(const GDALDatasetIdentifyAlgorithm &) = delete; 70 : }; 71 : 72 : //! @endcond 73 : 74 : #endif