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: 2025-01-18 12:42:00 Functions: 2 2 100.0 %

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

Generated by: LCOV version 1.14