LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/hana - ogrhanaresultlayer.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 20 21 95.2 %
Date: 2024-05-14 13:00:50 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  SAP HANA Spatial Driver
       4             :  * Purpose:  OGRHanaResultLayer class 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 "ogr_hana.h"
      30             : 
      31             : #include <memory>
      32             : 
      33             : #include "odbc/PreparedStatement.h"
      34             : #include "odbc/ResultSetMetaData.h"
      35             : 
      36             : namespace OGRHANA
      37             : {
      38             : 
      39             : /************************************************************************/
      40             : /*                              OGRHanaResultLayer()                    */
      41             : /************************************************************************/
      42             : 
      43          13 : OGRHanaResultLayer::OGRHanaResultLayer(OGRHanaDataSource *datasource,
      44          13 :                                        const char *query)
      45          13 :     : OGRHanaLayer(datasource)
      46             : {
      47          13 :     rawQuery_ = (query == nullptr) ? "" : query;
      48          13 :     SetDescription("sql_statement");
      49          13 : }
      50             : 
      51             : /************************************************************************/
      52             : /*                                Initialize()                          */
      53             : /************************************************************************/
      54             : 
      55          13 : OGRErr OGRHanaResultLayer::Initialize()
      56             : {
      57          13 :     if (initialized_)
      58           0 :         return OGRERR_NONE;
      59             : 
      60          13 :     auto names = dataSource_->FindSchemaAndTableNames(rawQuery_.c_str());
      61          13 :     OGRErr err = InitFeatureDefinition(names.first, names.second, rawQuery_,
      62             :                                        "sql_statement");
      63          13 :     return err;
      64             : }
      65             : 
      66             : /************************************************************************/
      67             : /*                           TestCapability()                           */
      68             : /************************************************************************/
      69             : 
      70          24 : int OGRHanaResultLayer::TestCapability(const char *capabilities)
      71             : {
      72          24 :     if (EQUAL(capabilities, OLCFastFeatureCount) ||
      73          24 :         EQUAL(capabilities, OLCFastSpatialFilter) ||
      74          24 :         EQUAL(capabilities, OLCFastGetExtent))
      75             :     {
      76           2 :         EnsureInitialized();
      77           2 :         return (geomColumns_.size() > 0);
      78             :     }
      79          22 :     if (EQUAL(capabilities, OLCStringsAsUTF8))
      80           1 :         return TRUE;
      81             : 
      82          21 :     return FALSE;
      83             : }
      84             : 
      85             : }  // namespace OGRHANA

Generated by: LCOV version 1.14