LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/hana - ogrhanadriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 15 24 62.5 %
Date: 2024-11-21 22:18:42 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  SAP HANA Spatial Driver
       4             :  * Purpose:  OGRHanaDriver functions implementation
       5             :  * Author:   Maxim Rylov
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2020, SAP SE
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "cpl_conv.h"
      14             : #include "ogr_hana.h"
      15             : #include "ogrhanadrivercore.h"
      16             : 
      17             : #include <memory>
      18             : 
      19             : /************************************************************************/
      20             : /*                         OGRHanaDriverOpen()                          */
      21             : /************************************************************************/
      22             : 
      23          65 : static GDALDataset *OGRHanaDriverOpen(GDALOpenInfo *openInfo)
      24             : {
      25          65 :     if (!OGRHanaDriverIdentify(openInfo))
      26           0 :         return nullptr;
      27             : 
      28         130 :     auto ds = std::make_unique<OGRHanaDataSource>();
      29         130 :     if (!ds->Open(openInfo->pszFilename, openInfo->papszOpenOptions,
      30          65 :                   openInfo->eAccess == GA_Update))
      31           9 :         return nullptr;
      32          56 :     return ds.release();
      33             : }
      34             : 
      35             : /************************************************************************/
      36             : /*                        OGRHanaDriverCreate()                         */
      37             : /************************************************************************/
      38             : 
      39           0 : static GDALDataset *OGRHanaDriverCreate(const char *name, CPL_UNUSED int nBands,
      40             :                                         CPL_UNUSED int nXSize,
      41             :                                         CPL_UNUSED int nYSize,
      42             :                                         CPL_UNUSED GDALDataType eDT,
      43             :                                         CPL_UNUSED char **options)
      44             : {
      45           0 :     auto ds = std::make_unique<OGRHanaDataSource>();
      46           0 :     if (!ds->Open(name, options, TRUE))
      47             :     {
      48           0 :         CPLError(CE_Failure, CPLE_AppDefined,
      49             :                  "HANA driver doesn't currently support database creation.\n"
      50             :                  "Please create a database with SAP HANA tools before using.");
      51             : 
      52           0 :         return nullptr;
      53             :     }
      54           0 :     return ds.release();
      55             : }
      56             : 
      57             : /************************************************************************/
      58             : /*                          RegisterOGRHANA()                           */
      59             : /************************************************************************/
      60             : 
      61          11 : void RegisterOGRHANA()
      62             : {
      63          11 :     if (!GDAL_CHECK_VERSION("SAP HANA driver"))
      64           0 :         return;
      65             : 
      66          11 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      67           0 :         return;
      68             : 
      69          22 :     auto driver = std::make_unique<GDALDriver>();
      70          11 :     OGRHANADriverSetCommonMetadata(driver.get());
      71          11 :     driver->pfnOpen = OGRHanaDriverOpen;
      72          11 :     driver->pfnCreate = OGRHanaDriverCreate;
      73             : 
      74          11 :     GetGDALDriverManager()->RegisterDriver(driver.release());
      75             : }

Generated by: LCOV version 1.14