LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/pgdump - ogr_pgdump.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 9 7 77.8 %
Date: 2011-12-18 Functions: 7 5 71.4 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogr_pgdump.h 22821 2011-07-28 17:54:47Z rouault $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Private definitions for OGR/PostgreSQL dump driver.
       6                 :  * Author:   Even Rouault, <even dot rouault at mines dash paris dot org>
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2010, Even Rouault
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #ifndef _OGR_PGDUMP_H_INCLUDED
      31                 : #define _OGR_PGDUMP_H_INCLUDED
      32                 : 
      33                 : #include "ogrsf_frmts.h"
      34                 : #include "cpl_string.h"
      35                 : 
      36                 : CPLString OGRPGDumpEscapeColumnName(const char* pszColumnName);
      37                 : CPLString OGRPGDumpEscapeString(   const char* pszStrValue, int nMaxLength,
      38                 :                                    const char* pszFieldName);
      39                 : 
      40                 : /************************************************************************/
      41                 : /*                          OGRPGDumpLayer                              */
      42                 : /************************************************************************/
      43                 : 
      44                 : 
      45                 : class OGRPGDumpDataSource;
      46                 : 
      47                 : class OGRPGDumpLayer : public OGRLayer
      48                 : {
      49                 :     char                *pszSqlTableName;
      50                 :     char                *pszGeomColumn;
      51                 :     char                *pszFIDColumn;
      52                 :     int                  nCoordDimension;
      53                 :     int                  nSRSId;
      54                 :     OGRFeatureDefn      *poFeatureDefn;
      55                 :     OGRPGDumpDataSource *poDS;
      56                 :     int                 nFeatures;
      57                 :     int                 bLaunderColumnNames;
      58                 :     int                 bPreservePrecision;
      59                 :     int                 bUseCopy;
      60                 :     int                 bWriteAsHex;
      61                 :     int                 bCopyActive;
      62                 :     int                 bCreateTable;
      63                 :     
      64                 :     void                AppendFieldValue(CPLString& osCommand,
      65                 :                                        OGRFeature* poFeature, int i);
      66                 :     char*               GByteArrayToBYTEA( const GByte* pabyData, int nLen);
      67                 :     char*               GeometryToHex( OGRGeometry * poGeometry, int nSRSId );
      68                 :     
      69                 :     OGRErr              StartCopy();
      70                 :     CPLString           BuildCopyFields();
      71                 :     
      72                 :   public:
      73                 :                         OGRPGDumpLayer(OGRPGDumpDataSource* poDS,
      74                 :                                        const char* pszSchemaName,
      75                 :                                        const char* pszLayerName,
      76                 :                                        const char* pszGeomColumn,
      77                 :                                        const char *pszFIDColumn,
      78                 :                                        int         nCoordDimension,
      79                 :                                        int         nSRSId,
      80                 :                                        int         bWriteAsHexIn,
      81                 :                                        int         bCreateTable);
      82                 :     virtual             ~OGRPGDumpLayer();
      83                 : 
      84               3 :     virtual OGRFeatureDefn *GetLayerDefn() {return poFeatureDefn;}
      85                 :     
      86               0 :     virtual void        ResetReading()  { }
      87                 :     virtual int         TestCapability( const char * );
      88                 :     
      89                 :     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
      90                 :     virtual OGRErr      CreateFeatureViaInsert( OGRFeature *poFeature );
      91                 :     virtual OGRErr      CreateFeatureViaCopy( OGRFeature *poFeature );
      92                 : 
      93                 :     virtual OGRErr      CreateField( OGRFieldDefn *poField,
      94                 :                                      int bApproxOK = TRUE );
      95                 :                                      
      96                 :     virtual OGRFeature *GetNextFeature();
      97                 : 
      98                 :     // follow methods are not base class overrides
      99               3 :     void                SetLaunderFlag( int bFlag )
     100               3 :                                 { bLaunderColumnNames = bFlag; }
     101               3 :     void                SetPrecisionFlag( int bFlag )
     102               3 :                                 { bPreservePrecision = bFlag; }
     103                 : 
     104                 :     OGRErr              EndCopy();
     105                 : };
     106                 : 
     107                 : /************************************************************************/
     108                 : /*                       OGRPGDumpDataSource                            */
     109                 : /************************************************************************/
     110                 : class OGRPGDumpDataSource : public OGRDataSource
     111                 : {
     112                 :     int                 nLayers;
     113                 :     OGRPGDumpLayer**    papoLayers;
     114                 :     char*               pszName;
     115                 :     int                 bTriedOpen;
     116                 :     VSILFILE*           fp;
     117                 :     int                 bInTransaction;
     118                 :     OGRPGDumpLayer*     poLayerInCopyMode;
     119                 :     const char*         pszEOL;
     120                 : 
     121                 :   public:
     122                 :                         OGRPGDumpDataSource(const char* pszName,
     123                 :                                             char** papszOptions);
     124                 :                         ~OGRPGDumpDataSource();
     125                 :                         
     126                 :     char               *LaunderName( const char *pszSrcName );
     127                 :     void                Log(const char* pszStr, int bAddSemiColumn = TRUE);
     128                 : 
     129               3 :     virtual const char  *GetName() { return pszName; }
     130               0 :     virtual int         GetLayerCount() { return nLayers; }
     131                 :     virtual OGRLayer   *GetLayer( int );
     132                 : 
     133                 :     virtual OGRLayer    *CreateLayer( const char *,
     134                 :                                       OGRSpatialReference * = NULL,
     135                 :                                       OGRwkbGeometryType = wkbUnknown,
     136                 :                                       char ** = NULL );
     137                 : 
     138                 :     virtual int         TestCapability( const char * );
     139                 : 
     140                 :     void                StartTransaction();
     141                 :     void                Commit();
     142                 : 
     143                 :     void                StartCopy( OGRPGDumpLayer *poPGLayer );
     144                 :     OGRErr              EndCopy( );
     145                 : };
     146                 : 
     147                 : /************************************************************************/
     148                 : /*                             OGRPGDriver                              */
     149                 : /************************************************************************/
     150                 : 
     151                 : class OGRPGDumpDriver : public OGRSFDriver
     152             178 : {
     153                 :   public:
     154                 :                 ~OGRPGDumpDriver();
     155                 : 
     156                 :     virtual const char    *GetName();
     157                 :     virtual OGRDataSource *Open( const char *, int );
     158                 : 
     159                 :     virtual OGRDataSource *CreateDataSource( const char *pszName,
     160                 :                                              char ** = NULL );
     161                 : 
     162                 :     virtual int            TestCapability( const char * );
     163                 : };
     164                 : 
     165                 : #endif /* ndef _OGR_PGDUMP_H_INCLUDED */
     166                 : 

Generated by: LCOV version 1.7