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-05-13 13:33:37 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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #include "cpl_conv.h"
      30             : #include "ogr_hana.h"
      31             : #include "ogrhanadrivercore.h"
      32             : 
      33             : #include <memory>
      34             : 
      35             : /************************************************************************/
      36             : /*                         OGRHanaDriverOpen()                          */
      37             : /************************************************************************/
      38             : 
      39          61 : static GDALDataset *OGRHanaDriverOpen(GDALOpenInfo *openInfo)
      40             : {
      41          61 :     if (!OGRHanaDriverIdentify(openInfo))
      42           0 :         return nullptr;
      43             : 
      44         122 :     auto ds = std::make_unique<OGRHanaDataSource>();
      45         122 :     if (!ds->Open(openInfo->pszFilename, openInfo->papszOpenOptions,
      46          61 :                   openInfo->eAccess == GA_Update))
      47           9 :         return nullptr;
      48          52 :     return ds.release();
      49             : }
      50             : 
      51             : /************************************************************************/
      52             : /*                        OGRHanaDriverCreate()                         */
      53             : /************************************************************************/
      54             : 
      55           0 : static GDALDataset *OGRHanaDriverCreate(const char *name, CPL_UNUSED int nBands,
      56             :                                         CPL_UNUSED int nXSize,
      57             :                                         CPL_UNUSED int nYSize,
      58             :                                         CPL_UNUSED GDALDataType eDT,
      59             :                                         CPL_UNUSED char **options)
      60             : {
      61           0 :     auto ds = std::make_unique<OGRHanaDataSource>();
      62           0 :     if (!ds->Open(name, options, TRUE))
      63             :     {
      64           0 :         CPLError(CE_Failure, CPLE_AppDefined,
      65             :                  "HANA driver doesn't currently support database creation.\n"
      66             :                  "Please create a database with SAP HANA tools before using.");
      67             : 
      68           0 :         return nullptr;
      69             :     }
      70           0 :     return ds.release();
      71             : }
      72             : 
      73             : /************************************************************************/
      74             : /*                          RegisterOGRHANA()                           */
      75             : /************************************************************************/
      76             : 
      77           9 : void RegisterOGRHANA()
      78             : {
      79           9 :     if (!GDAL_CHECK_VERSION("SAP HANA driver"))
      80           0 :         return;
      81             : 
      82           9 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      83           0 :         return;
      84             : 
      85          18 :     auto driver = std::make_unique<GDALDriver>();
      86           9 :     OGRHANADriverSetCommonMetadata(driver.get());
      87           9 :     driver->pfnOpen = OGRHanaDriverOpen;
      88           9 :     driver->pfnCreate = OGRHanaDriverCreate;
      89             : 
      90           9 :     GetGDALDriverManager()->RegisterDriver(driver.release());
      91             : }

Generated by: LCOV version 1.14