LCOV - code coverage report
Current view: top level - apps - gdalalg_info.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 10 10 100.0 %
Date: 2025-06-19 12:30:01 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "info" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "cpl_error.h"
      14             : #include "gdalalgorithm.h"
      15             : #include "gdalalg_raster_info.h"
      16             : #include "gdalalg_vector_info.h"
      17             : #include "gdalalg_dispatcher.h"
      18             : #include "gdal_priv.h"
      19             : 
      20             : /************************************************************************/
      21             : /*                          GDALInfoAlgorithm                           */
      22             : /************************************************************************/
      23             : 
      24          50 : class GDALInfoAlgorithm final
      25             :     : public GDALDispatcherAlgorithm<GDALRasterInfoAlgorithm,
      26             :                                      GDALVectorInfoAlgorithm>
      27             : {
      28             :   public:
      29             :     static constexpr const char *NAME = "info";
      30             :     static constexpr const char *DESCRIPTION =
      31             :         "Return information on a dataset (shortcut for 'gdal raster info' or "
      32             :         "'gdal vector info').";
      33             :     static constexpr const char *HELP_URL = "/programs/gdal_info.html";
      34             : 
      35          25 :     GDALInfoAlgorithm() : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL)
      36             :     {
      37             :         // only for the help message
      38          25 :         AddOutputFormatArg(&m_format).SetDefault("json").SetChoices("json",
      39          25 :                                                                     "text");
      40          25 :         AddInputDatasetArg(&m_dataset);
      41             : 
      42             :         m_longDescription = "For all options, run 'gdal raster info --help' or "
      43          25 :                             "'gdal vector info --help'";
      44          25 :     }
      45             : 
      46             :     ~GDALInfoAlgorithm() override;
      47             : 
      48             :   private:
      49             :     std::unique_ptr<GDALRasterInfoAlgorithm> m_rasterInfo{};
      50             :     std::unique_ptr<GDALVectorInfoAlgorithm> m_vectorInfo{};
      51             : 
      52             :     std::string m_format{};
      53             :     GDALArgDatasetValue m_dataset{};
      54             : 
      55           2 :     bool RunImpl(GDALProgressFunc, void *) override
      56             :     {
      57           2 :         CPLError(CE_Failure, CPLE_AppDefined,
      58             :                  "The Run() method should not be called directly on the \"gdal "
      59             :                  "info\" program.");
      60           2 :         return false;
      61             :     }
      62             : };
      63             : 
      64             : GDALInfoAlgorithm::~GDALInfoAlgorithm() = default;
      65             : 
      66             : GDAL_STATIC_REGISTER_ALG(GDALInfoAlgorithm);

Generated by: LCOV version 1.14