LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/elastic - ogrelasticdriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 22 24 91.7 %
Date: 2024-05-18 15:15:27 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  Elasticsearch Translator
       4             :  * Purpose:
       5             :  * Author:
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2011, Adam Estrada
       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 "ogr_elastic.h"
      30             : #include "cpl_conv.h"
      31             : #include "ogrelasticdrivercore.h"
      32             : 
      33             : /************************************************************************/
      34             : /*                  OGRElasticsearchDriverOpen()                        */
      35             : /************************************************************************/
      36             : 
      37          30 : static GDALDataset *OGRElasticsearchDriverOpen(GDALOpenInfo *poOpenInfo)
      38             : 
      39             : {
      40          30 :     if (!OGRElasticsearchDriverIdentify(poOpenInfo))
      41           0 :         return nullptr;
      42             : 
      43          30 :     OGRElasticDataSource *poDS = new OGRElasticDataSource();
      44          30 :     if (!poDS->Open(poOpenInfo))
      45             :     {
      46           6 :         delete poDS;
      47           6 :         poDS = nullptr;
      48             :     }
      49             : 
      50          30 :     return poDS;
      51             : }
      52             : 
      53             : /************************************************************************/
      54             : /*                     OGRElasticsearchDriverCreate()                   */
      55             : /************************************************************************/
      56             : static GDALDataset *
      57          10 : OGRElasticsearchDriverCreate(const char *pszName, CPL_UNUSED int nXSize,
      58             :                              CPL_UNUSED int nYSize, CPL_UNUSED int nBands,
      59             :                              CPL_UNUSED GDALDataType eDT, char **papszOptions)
      60             : {
      61          10 :     OGRElasticDataSource *poDS = new OGRElasticDataSource();
      62             : 
      63          10 :     if (!poDS->Create(pszName, papszOptions))
      64             :     {
      65           2 :         delete poDS;
      66           2 :         poDS = nullptr;
      67             :     }
      68             : 
      69          10 :     return poDS;
      70             : }
      71             : 
      72             : /************************************************************************/
      73             : /*                          RegisterOGRElastic()                        */
      74             : /************************************************************************/
      75             : 
      76        1523 : void RegisterOGRElastic()
      77             : {
      78        1523 :     if (!GDAL_CHECK_VERSION("OGR/Elastic Search driver"))
      79           0 :         return;
      80             : 
      81        1523 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      82         301 :         return;
      83             : 
      84        1222 :     GDALDriver *poDriver = new GDALDriver();
      85        1222 :     OGRElasticsearchDriverSetCommonMetadata(poDriver);
      86        1222 :     poDriver->pfnOpen = OGRElasticsearchDriverOpen;
      87        1222 :     poDriver->pfnCreate = OGRElasticsearchDriverCreate;
      88             : 
      89        1222 :     GetGDALDriverManager()->RegisterDriver(poDriver);
      90             : }

Generated by: LCOV version 1.14