LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/csv - ogr_csv.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 6 6 100.0 %
Date: 2012-04-28 Functions: 5 5 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogr_csv.h 21806 2011-02-22 22:57:12Z rouault $
       3                 :  *
       4                 :  * Project:  CSV Translator
       5                 :  * Purpose:  Definition of classes for OGR .csv driver.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2004,  Frank Warmerdam
      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_CSV_H_INCLUDED
      31                 : #define _OGR_CSV_H_INCLUDED
      32                 : 
      33                 : #include "ogrsf_frmts.h"
      34                 : 
      35                 : typedef enum
      36                 : {
      37                 :     OGR_CSV_GEOM_NONE,
      38                 :     OGR_CSV_GEOM_AS_WKT,
      39                 :     OGR_CSV_GEOM_AS_XYZ,
      40                 :     OGR_CSV_GEOM_AS_XY,
      41                 :     OGR_CSV_GEOM_AS_YX,
      42                 : } OGRCSVGeometryFormat;
      43                 : 
      44                 : class OGRCSVDataSource;
      45                 : 
      46                 : char **OGRCSVReadParseLineL( VSILFILE * fp, char chDelimiter, int bDontHonourStrings );
      47                 : 
      48                 : /************************************************************************/
      49                 : /*                             OGRCSVLayer                              */
      50                 : /************************************************************************/
      51                 : 
      52                 : class OGRCSVLayer : public OGRLayer
      53                 : {
      54                 :     OGRFeatureDefn     *poFeatureDefn;
      55                 : 
      56                 :     VSILFILE           *fpCSV;
      57                 : 
      58                 :     int                 nNextFID;
      59                 : 
      60                 :     int                 bHasFieldNames;
      61                 : 
      62                 :     OGRFeature *        GetNextUnfilteredFeature();
      63                 : 
      64                 :     int                 bNew;
      65                 :     int                 bInWriteMode;
      66                 :     int                 bUseCRLF;
      67                 :     int                 bNeedRewindBeforeRead;
      68                 :     OGRCSVGeometryFormat eGeometryFormat;
      69                 : 
      70                 :     char*               pszFilename;
      71                 :     int                 bCreateCSVT;
      72                 :     char                chDelimiter;
      73                 : 
      74                 :     int                 iWktGeomReadField;
      75                 :     int                 bFirstFeatureAppendedDuringSession;
      76                 : 
      77                 :     /*http://www.faa.gov/airports/airport_safety/airportdata_5010/menu/index.cfm specific */
      78                 :     int                 iNfdcLatitudeS, iNfdcLongitudeS;
      79                 :     int                 bDontHonourStrings;
      80                 : 
      81                 :     /* GNIS specific */
      82                 :     int                 iLongitudeField, iLatitudeField;
      83                 : 
      84                 :     int                 nTotalFeatures;
      85                 : 
      86                 :   public:
      87                 :     OGRCSVLayer( const char *pszName, VSILFILE *fp, const char *pszFilename,
      88                 :                  int bNew, int bInWriteMode, char chDelimiter,
      89                 :                  const char* pszNfdcRunwaysGeomField,
      90                 :                  const char* pszGeonamesGeomFieldPrefix );
      91                 :   ~OGRCSVLayer();
      92                 : 
      93                 :     void                ResetReading();
      94                 :     OGRFeature *        GetNextFeature();
      95                 : 
      96           56640 :     OGRFeatureDefn *    GetLayerDefn() { return poFeatureDefn; }
      97                 : 
      98                 :     int                 TestCapability( const char * );
      99                 : 
     100                 :     virtual OGRErr      CreateField( OGRFieldDefn *poField,
     101                 :                                      int bApproxOK = TRUE );
     102                 : 
     103                 :     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
     104                 : 
     105                 :     void                SetCRLF(int);
     106                 :     void                SetWriteGeometry(OGRCSVGeometryFormat eGeometryFormat);
     107                 :     void                SetCreateCSVT(int bCreateCSVT);
     108                 : 
     109                 :     virtual int         GetFeatureCount( int bForce = TRUE );
     110                 : };
     111                 : 
     112                 : /************************************************************************/
     113                 : /*                           OGRCSVDataSource                           */
     114                 : /************************************************************************/
     115                 : 
     116                 : class OGRCSVDataSource : public OGRDataSource
     117                 : {
     118                 :     char                *pszName;
     119                 : 
     120                 :     OGRCSVLayer       **papoLayers;
     121                 :     int                 nLayers;
     122                 : 
     123                 :     int                 bUpdate;
     124                 : 
     125                 :     CPLString           osDefaultCSVName;
     126                 : 
     127                 :   public:
     128                 :                         OGRCSVDataSource();
     129                 :                         ~OGRCSVDataSource();
     130                 : 
     131                 :     int                 Open( const char * pszFilename,
     132                 :                               int bUpdate, int bForceAccept );
     133                 :     int                 OpenTable( const char * pszFilename,
     134                 :                                    const char* pszNfdcRunwaysGeomField = NULL,
     135                 :                                    const char* pszGeonamesGeomFieldPrefix = NULL);
     136                 :     
     137              66 :     const char          *GetName() { return pszName; }
     138                 : 
     139             274 :     int                 GetLayerCount() { return nLayers; }
     140                 :     OGRLayer            *GetLayer( int );
     141                 : 
     142                 :     virtual OGRLayer   *CreateLayer( const char *pszName, 
     143                 :                                      OGRSpatialReference *poSpatialRef = NULL,
     144                 :                                      OGRwkbGeometryType eGType = wkbUnknown,
     145                 :                                      char ** papszOptions = NULL );
     146                 : 
     147                 :     virtual OGRErr      DeleteLayer(int);
     148                 : 
     149                 :     int                 TestCapability( const char * );
     150                 : 
     151               2 :     void                SetDefaultCSVName( const char *pszName ) 
     152               2 :         { osDefaultCSVName = pszName; }
     153                 : };
     154                 : 
     155                 : /************************************************************************/
     156                 : /*                             OGRCSVDriver                             */
     157                 : /************************************************************************/
     158                 : 
     159                 : class OGRCSVDriver : public OGRSFDriver
     160             389 : {
     161                 :   public:
     162                 :                 ~OGRCSVDriver();
     163                 :                 
     164                 :     const char *GetName();
     165                 :     OGRDataSource *Open( const char *, int );
     166                 :     OGRDataSource *CreateDataSource( const char *, char ** );
     167                 :     int         TestCapability( const char * );
     168                 : 
     169                 :     virtual OGRErr      DeleteDataSource( const char *pszName );
     170                 :     
     171                 : };
     172                 : 
     173                 : 
     174                 : #endif /* ndef _OGR_CSV_H_INCLUDED */

Generated by: LCOV version 1.7