LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/pgeo - ogr_pgeo.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 14 0.0 %
Date: 2025-02-18 14:19:29 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  OpenGIS Simple Features Reference Implementation
       4             :  * Purpose:  Private definitions for Personal Geodatabase driver.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
       9             :  * Copyright (c) 2009-2013, Even Rouault <even dot rouault at spatialys.com>
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #ifndef OGR_ODBC_H_INCLUDED
      15             : #define OGR_ODBC_H_INCLUDED
      16             : 
      17             : #include "ogrsf_frmts.h"
      18             : #include "cpl_odbc.h"
      19             : #include "cpl_error.h"
      20             : 
      21             : #include <unordered_set>
      22             : 
      23             : /************************************************************************/
      24             : /*                            OGRPGeoLayer                              */
      25             : /************************************************************************/
      26             : 
      27             : class OGRPGeoDataSource;
      28             : 
      29             : constexpr const char *pszRelationshipTypeUUID =
      30             :     "{B606A7E1-FA5B-439C-849C6E9C2481537B}";
      31             : 
      32             : class OGRPGeoLayer CPL_NON_FINAL : public OGRLayer
      33             : {
      34             :   protected:
      35             :     OGRFeatureDefn *poFeatureDefn;
      36             : 
      37             :     int m_nStatementFlags = 0;
      38             : 
      39             :     CPLODBCStatement *poStmt;
      40             : 
      41             :     // Layer spatial reference system, and srid.
      42             :     OGRSpatialReference *poSRS;
      43             :     int nSRSId;
      44             : 
      45             :     GIntBig iNextShapeId;
      46             : 
      47             :     OGRPGeoDataSource *poDS;
      48             : 
      49             :     char *pszGeomColumn;
      50             :     char *pszFIDColumn;
      51             : 
      52             :     int *panFieldOrdinals;
      53             : 
      54             :     bool m_bEOF = false;
      55             : 
      56             :     CPLErr BuildFeatureDefn(const char *pszLayerName, CPLODBCStatement *poStmt);
      57             : 
      58           0 :     virtual CPLODBCStatement *GetStatement()
      59             :     {
      60           0 :         return poStmt;
      61             :     }
      62             : 
      63             :     void LookupSRID(int);
      64             : 
      65             :   public:
      66             :     OGRPGeoLayer();
      67             :     virtual ~OGRPGeoLayer();
      68             : 
      69             :     virtual void ResetReading() override;
      70             :     virtual OGRFeature *GetNextRawFeature();
      71             :     virtual OGRFeature *GetNextFeature() override;
      72             : 
      73             :     virtual OGRFeature *GetFeature(GIntBig nFeatureId) override;
      74             : 
      75           0 :     OGRFeatureDefn *GetLayerDefn() override
      76             :     {
      77           0 :         return poFeatureDefn;
      78             :     }
      79             : 
      80             :     virtual int TestCapability(const char *) override;
      81             : 
      82             :     virtual const char *GetFIDColumn() override;
      83             :     virtual const char *GetGeometryColumn() override;
      84             : };
      85             : 
      86             : /************************************************************************/
      87             : /*                           OGRPGeoTableLayer                            */
      88             : /************************************************************************/
      89             : 
      90             : class OGRPGeoTableLayer final : public OGRPGeoLayer
      91             : {
      92             :     char *pszQuery;
      93             : 
      94             :     void ClearStatement();
      95             :     OGRErr ResetStatement();
      96             : 
      97             :     virtual CPLODBCStatement *GetStatement() override;
      98             : 
      99             :     OGREnvelope sExtent;
     100             :     std::string m_osDefinition;
     101             :     std::string m_osDocumentation;
     102             : 
     103             :   public:
     104             :     explicit OGRPGeoTableLayer(OGRPGeoDataSource *, int);
     105             :     virtual ~OGRPGeoTableLayer();
     106             : 
     107             :     CPLErr Initialize(const char *pszTableName, const char *pszGeomCol,
     108             :                       int nShapeType, double dfExtentLeft, double dfExtentRight,
     109             :                       double dfExtentBottom, double dfExtentTop, int nSRID,
     110             :                       int bHasZ, int nHasM);
     111             : 
     112             :     virtual void ResetReading() override;
     113             :     virtual GIntBig GetFeatureCount(int) override;
     114             : 
     115             :     virtual OGRErr SetAttributeFilter(const char *) override;
     116             :     virtual OGRFeature *GetFeature(GIntBig nFeatureId) override;
     117             : 
     118             :     virtual int TestCapability(const char *) override;
     119             : 
     120             :     virtual OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
     121             :                               bool bForce) override;
     122             : 
     123           0 :     const std::string &GetXMLDefinition()
     124             :     {
     125           0 :         return m_osDefinition;
     126             :     }
     127             : 
     128           0 :     const std::string &GetXMLDocumentation()
     129             :     {
     130           0 :         return m_osDocumentation;
     131             :     }
     132             : };
     133             : 
     134             : /************************************************************************/
     135             : /*                          OGRPGeoSelectLayer                          */
     136             : /************************************************************************/
     137             : 
     138             : class OGRPGeoSelectLayer final : public OGRPGeoLayer
     139             : {
     140             :     char *pszBaseStatement;
     141             : 
     142             :     void ClearStatement();
     143             :     OGRErr ResetStatement();
     144             : 
     145             :     virtual CPLODBCStatement *GetStatement() override;
     146             : 
     147             :   public:
     148             :     OGRPGeoSelectLayer(OGRPGeoDataSource *, CPLODBCStatement *);
     149             :     virtual ~OGRPGeoSelectLayer();
     150             : 
     151             :     virtual void ResetReading() override;
     152             :     virtual GIntBig GetFeatureCount(int) override;
     153             : 
     154             :     virtual OGRFeature *GetFeature(GIntBig nFeatureId) override;
     155             : 
     156             :     virtual int TestCapability(const char *) override;
     157             : };
     158             : 
     159             : /************************************************************************/
     160             : /*                           OGRPGeoDataSource                          */
     161             : /************************************************************************/
     162             : 
     163             : class OGRPGeoDataSource final : public GDALDataset
     164             : {
     165             :     OGRPGeoLayer **papoLayers;
     166             :     int nLayers;
     167             : 
     168             :     mutable CPLODBCSession oSession;
     169             : 
     170             :     std::unordered_set<std::string> m_aosAllLCTableNames;
     171             :     bool m_bHasGdbItemsTable = false;
     172             : 
     173             :     std::vector<std::unique_ptr<OGRLayer>> m_apoInvisibleLayers;
     174             : 
     175             :     std::map<std::string, std::unique_ptr<GDALRelationship>>
     176             :         m_osMapRelationships{};
     177             : 
     178             : #ifndef _WIN32
     179             :     mutable bool m_COUNT_STAR_state_known = false;
     180             :     mutable bool m_COUNT_STAR_working = false;
     181             : #endif
     182             : 
     183             :     int m_nStatementFlags = 0;
     184             : 
     185             :     static bool IsPrivateLayerName(const CPLString &osName);
     186             : 
     187             :   public:
     188             :     OGRPGeoDataSource();
     189             :     virtual ~OGRPGeoDataSource();
     190             : 
     191             :     int Open(GDALOpenInfo *poOpenInfo);
     192             :     int OpenTable(const char *pszTableName, const char *pszGeomCol,
     193             :                   int bUpdate);
     194             : 
     195           0 :     int GetLayerCount() override
     196             :     {
     197           0 :         return nLayers;
     198             :     }
     199             : 
     200             :     OGRLayer *GetLayer(int) override;
     201             :     OGRLayer *GetLayerByName(const char *) override;
     202             :     bool IsLayerPrivate(int) const override;
     203             : 
     204             :     int TestCapability(const char *) override;
     205             : 
     206             :     virtual OGRLayer *ExecuteSQL(const char *pszSQLCommand,
     207             :                                  OGRGeometry *poSpatialFilter,
     208             :                                  const char *pszDialect) override;
     209             :     virtual void ReleaseResultSet(OGRLayer *poLayer) override;
     210             : 
     211             :     std::vector<std::string>
     212             :     GetRelationshipNames(CSLConstList papszOptions = nullptr) const override;
     213             : 
     214             :     const GDALRelationship *
     215             :     GetRelationship(const std::string &name) const override;
     216             : 
     217             :     // Internal use
     218           0 :     CPLODBCSession *GetSession()
     219             :     {
     220           0 :         return &oSession;
     221             :     }
     222             : 
     223             :     bool CountStarWorking() const;
     224             : 
     225           0 :     bool HasGdbItemsTable() const
     226             :     {
     227           0 :         return m_bHasGdbItemsTable;
     228             :     }
     229             : };
     230             : 
     231             : #endif /* ndef _OGR_PGeo_H_INCLUDED */

Generated by: LCOV version 1.14