LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/vfk - vfkreaderp.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 12 20 60.0 %
Date: 2024-05-04 12:52:34 Functions: 6 10 60.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  VFK Reader
       5             :  * Purpose:  Private Declarations for OGR free VFK Reader code.
       6             :  * Author:   Martin Landa, landa.martin gmail.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2012-2018, Martin Landa <landa.martin gmail.com>
      10             :  *
      11             :  * Permission is hereby granted, free of charge, to any person
      12             :  * obtaining a copy of this software and associated documentation
      13             :  * files (the "Software"), to deal in the Software without
      14             :  * restriction, including without limitation the rights to use, copy,
      15             :  * modify, merge, publish, distribute, sublicense, and/or sell copies
      16             :  * of the Software, and to permit persons to whom the Software is
      17             :  * furnished to do so, subject to the following conditions:
      18             :  *
      19             :  * The above copyright notice and this permission notice shall be
      20             :  * included in all copies or substantial portions of the Software.
      21             :  *
      22             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      23             :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      24             :  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      25             :  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
      26             :  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
      27             :  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
      28             :  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      29             :  * SOFTWARE.
      30             :  ****************************************************************************/
      31             : 
      32             : #ifndef GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
      33             : #define GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
      34             : 
      35             : #include <map>
      36             : #include <string>
      37             : 
      38             : #include "vfkreader.h"
      39             : #include "ogr_api.h"
      40             : 
      41             : #include "sqlite3.h"
      42             : 
      43             : class VFKReader;
      44             : 
      45             : /************************************************************************/
      46             : /*                              VFKReader                               */
      47             : /************************************************************************/
      48             : class VFKReader : public IVFKReader
      49             : {
      50             :   private:
      51             :     const char *m_pszEncoding;
      52             : 
      53             :     VSILFILE *m_poFD;
      54             :     char *ReadLine();
      55             : 
      56             :     void AddInfo(const char *) override;
      57             : 
      58             :     CPL_DISALLOW_COPY_ASSIGN(VFKReader)
      59             : 
      60             :   protected:
      61             :     char *m_pszFilename;
      62             :     VSIStatBufL *m_poFStat;
      63             :     bool m_bAmendment;
      64             :     bool m_bFileField;
      65             :     int m_nDataBlockCount;
      66             :     IVFKDataBlock **m_papoDataBlock;
      67             : 
      68             :     IVFKDataBlock *CreateDataBlock(const char *) override;
      69             :     void AddDataBlock(IVFKDataBlock *, const char *) override;
      70             :     virtual OGRErr AddFeature(IVFKDataBlock *, VFKFeature *) override;
      71             :     void ReadEncoding();
      72             : 
      73             :     // Metadata.
      74             :     std::map<CPLString, CPLString> poInfo;
      75             : 
      76             :   public:
      77             :     explicit VFKReader(const GDALOpenInfo *);
      78             :     virtual ~VFKReader();
      79             : 
      80           1 :     const char *GetFilename() const override
      81             :     {
      82           1 :         return m_pszFilename;
      83             :     }
      84             : 
      85        9232 :     const char *GetEncoding() const override
      86             :     {
      87        9232 :         return m_pszEncoding;
      88             :     }
      89             : 
      90           0 :     bool IsSpatial() const override
      91             :     {
      92           0 :         return false;
      93             :     }
      94             : 
      95           0 :     bool IsPreProcessed() const override
      96             :     {
      97           0 :         return false;
      98             :     }
      99             : 
     100           0 :     bool IsValid() const override
     101             :     {
     102           0 :         return true;
     103             :     }
     104             : 
     105        1007 :     bool HasFileField() const override
     106             :     {
     107        1007 :         return m_bFileField;
     108             :     }
     109             : 
     110             :     int ReadDataBlocks(bool = false) override;
     111             :     int ReadDataRecords(IVFKDataBlock * = nullptr) override;
     112             :     int LoadGeometry() override;
     113             : 
     114        5720 :     int GetDataBlockCount() const override
     115             :     {
     116        5720 :         return m_nDataBlockCount;
     117             :     }
     118             : 
     119             :     IVFKDataBlock *GetDataBlock(int) const override;
     120             :     IVFKDataBlock *GetDataBlock(const char *) const override;
     121             : 
     122             :     const char *GetInfo(const char *) override;
     123             : };
     124             : 
     125             : /************************************************************************/
     126             : /*                              VFKReaderSQLite                         */
     127             : /************************************************************************/
     128             : 
     129             : class VFKReaderSQLite : public VFKReader
     130             : {
     131             :   private:
     132             :     char *m_pszDBname;
     133             :     sqlite3 *m_poDB;
     134             :     bool m_bSpatial;
     135             :     bool m_bNewDb;
     136             :     bool m_bDbSource;
     137             : 
     138             :     IVFKDataBlock *CreateDataBlock(const char *) override;
     139             :     void AddDataBlock(IVFKDataBlock *, const char *) override;
     140             :     OGRErr AddFeature(IVFKDataBlock *, VFKFeature *) override;
     141             : 
     142             :     void StoreInfo2DB();
     143             : 
     144             :     void CreateIndex(const char *, const char *, const char *, bool = true);
     145             :     void CreateIndices();
     146             : 
     147             :     friend class VFKFeatureSQLite;
     148             : 
     149             :   public:
     150             :     explicit VFKReaderSQLite(const GDALOpenInfo *);
     151             :     virtual ~VFKReaderSQLite();
     152             : 
     153        1134 :     bool IsSpatial() const override
     154             :     {
     155        1134 :         return m_bSpatial;
     156             :     }
     157             : 
     158           0 :     bool IsPreProcessed() const override
     159             :     {
     160           0 :         return !m_bNewDb;
     161             :     }
     162             : 
     163          17 :     bool IsValid() const override
     164             :     {
     165          17 :         return m_poDB != nullptr;
     166             :     }
     167             : 
     168             :     int ReadDataBlocks(bool = false) override;
     169             :     int ReadDataRecords(IVFKDataBlock * = nullptr) override;
     170             : 
     171             :     sqlite3_stmt *PrepareStatement(const char *);
     172             :     OGRErr ExecuteSQL(const char *, CPLErr = CE_Failure);
     173             :     OGRErr ExecuteSQL(sqlite3_stmt *&);
     174             : };
     175             : 
     176             : #endif  // GDAL_OGR_VFK_VFKREADERP_H_INCLUDED

Generated by: LCOV version 1.14