LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/sqlite - ogrsqliteutility.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2024-11-25 13:07:18 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  GeoPackage Translator
       5             :  * Purpose:  Utility header for OGR GeoPackage driver.
       6             :  * Author:   Paul Ramsey, pramsey@boundlessgeo.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2013, Paul Ramsey <pramsey@boundlessgeo.com>
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #ifndef OGR_SQLITEUTILITY_H_INCLUDED
      15             : #define OGR_SQLITEUTILITY_H_INCLUDED
      16             : 
      17             : #include "ogr_core.h"
      18             : #include "cpl_string.h"
      19             : #include "sqlite3.h"
      20             : 
      21             : #include <set>
      22             : #include <string>
      23             : #include <memory>
      24             : #include <vector>
      25             : 
      26             : class SQLResult
      27             : {
      28             :   public:
      29             :     SQLResult(char **result, int nRow, int nCol);
      30             :     ~SQLResult();
      31             : 
      32       56369 :     int RowCount() const
      33             :     {
      34       56369 :         return nRowCount;
      35             :     }
      36             : 
      37         755 :     int ColCount() const
      38             :     {
      39         755 :         return nColCount;
      40             :     }
      41             : 
      42             :     void LimitRowCount(int nLimit);
      43             : 
      44             :     const char *GetValue(int iColumnNum, int iRowNum) const;
      45             :     int GetValueAsInteger(int iColNum, int iRowNum) const;
      46             :     double GetValueAsDouble(int iColNum, int iRowNum) const;
      47             : 
      48             :   private:
      49             :     char **papszResult = nullptr;
      50             :     int nRowCount = 0;
      51             :     int nColCount = 0;
      52             : 
      53             :     CPL_DISALLOW_COPY_ASSIGN(SQLResult)
      54             : };
      55             : 
      56             : OGRErr SQLCommand(sqlite3 *poDb, const char *pszSQL);
      57             : int SQLGetInteger(sqlite3 *poDb, const char *pszSQL, OGRErr *err);
      58             : GIntBig SQLGetInteger64(sqlite3 *poDb, const char *pszSQL, OGRErr *err);
      59             : 
      60             : std::unique_ptr<SQLResult> SQLQuery(sqlite3 *poDb, const char *pszSQL);
      61             : 
      62             : /* To escape literals. The returned string doesn't contain the surrounding
      63             :  * single quotes */
      64             : CPLString SQLEscapeLiteral(const char *pszLiteral);
      65             : 
      66             : /* To escape table or field names. The returned string doesn't contain the
      67             :  * surrounding double quotes */
      68             : CPLString SQLEscapeName(const char *pszName);
      69             : 
      70             : /* Remove leading ' or " and unescape in that case. Or return string unmodified
      71             :  */
      72             : CPLString SQLUnescape(const char *pszVal);
      73             : 
      74             : char **SQLTokenize(const char *pszSQL);
      75             : 
      76             : struct SQLSqliteMasterContent
      77             : {
      78             :     std::string osSQL{};
      79             :     std::string osType{};
      80             :     std::string osTableName{};
      81             : };
      82             : 
      83             : std::set<std::string> SQLGetUniqueFieldUCConstraints(
      84             :     sqlite3 *poDb, const char *pszTableName,
      85             :     const std::vector<SQLSqliteMasterContent> &sqliteMasterContent =
      86             :         std::vector<SQLSqliteMasterContent>());
      87             : 
      88             : bool OGRSQLiteRTreeRequiresTrustedSchemaOn();
      89             : 
      90             : bool OGRSQLiteIsSpatialFunctionReturningGeometry(const char *pszName);
      91             : 
      92             : class GDALDataset;
      93             : 
      94             : void OGRSQLite_gdal_get_pixel_value_common(const char *pszFunctionName,
      95             :                                            sqlite3_context *pContext, int argc,
      96             :                                            sqlite3_value **argv,
      97             :                                            GDALDataset *poDS);
      98             : 
      99             : #endif  // OGR_SQLITEUTILITY_H_INCLUDED

Generated by: LCOV version 1.14