LCOV - code coverage report
Current view: top level - apps - gdalalg_info.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 9 9 100.0 %
Date: 2025-09-10 17:48:50 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          56 : 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          28 :     GDALInfoAlgorithm() : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL)
      36             :     {
      37             :         // only for the help message
      38          28 :         AddOutputFormatArg(&m_format).SetChoices("json", "text");
      39          28 :         AddInputDatasetArg(&m_dataset);
      40             : 
      41             :         m_longDescription = "For all options, run 'gdal raster info --help' or "
      42          28 :                             "'gdal vector info --help'";
      43          28 :     }
      44             : 
      45             :     ~GDALInfoAlgorithm() override;
      46             : 
      47             :   private:
      48             :     std::unique_ptr<GDALRasterInfoAlgorithm> m_rasterInfo{};
      49             :     std::unique_ptr<GDALVectorInfoAlgorithm> m_vectorInfo{};
      50             : 
      51             :     std::string m_format{};
      52             :     GDALArgDatasetValue m_dataset{};
      53             : 
      54           2 :     bool RunImpl(GDALProgressFunc, void *) override
      55             :     {
      56           2 :         CPLError(CE_Failure, CPLE_AppDefined,
      57             :                  "The Run() method should not be called directly on the \"gdal "
      58             :                  "info\" program.");
      59           2 :         return false;
      60             :     }
      61             : };
      62             : 
      63             : GDALInfoAlgorithm::~GDALInfoAlgorithm() = default;
      64             : 
      65             : GDAL_STATIC_REGISTER_ALG(GDALInfoAlgorithm);

Generated by: LCOV version 1.14