LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/mssqlspatial - ogrmssqlspatialdriver.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 29 10 34.5 %
Date: 2012-12-26 Functions: 8 4 50.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrmssqlspatialdriver.cpp 20570 2010-09-11 20:40:59Z tamas $
       3                 :  *
       4                 :  * Project:  MSSQL Spatial driver
       5                 :  * Purpose:  Definition of classes for OGR MSSQL Spatial driver.
       6                 :  * Author:   Tamas Szekeres, szekerest at gmail.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2010, Tamas Szekeres
      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                 : #include "ogr_mssqlspatial.h"
      31                 : #include "cpl_conv.h"
      32                 : 
      33                 : CPL_CVSID("$Id: ogrmssqlspatialdriver.cpp 20570 2010-09-11 20:40:59Z tamas $");
      34                 : 
      35                 : /************************************************************************/
      36                 : /*                           ~OGRMSSQLSpatialDriver()                   */
      37                 : /************************************************************************/
      38                 : 
      39             214 : OGRMSSQLSpatialDriver::~OGRMSSQLSpatialDriver()
      40                 : 
      41                 : {
      42             214 : }
      43                 : 
      44                 : /************************************************************************/
      45                 : /*                              GetName()                               */
      46                 : /************************************************************************/
      47                 : 
      48           13895 : const char *OGRMSSQLSpatialDriver::GetName()
      49                 : 
      50                 : {
      51           13895 :     return "MSSQLSpatial";
      52                 : }
      53                 : 
      54                 : /************************************************************************/
      55                 : /*                                Open()                                */
      56                 : /************************************************************************/
      57                 : 
      58             328 : OGRDataSource *OGRMSSQLSpatialDriver::Open( const char * pszFilename, int bUpdate )
      59                 : 
      60                 : {
      61                 :     OGRMSSQLSpatialDataSource     *poDS;
      62                 : 
      63             328 :     if( !EQUALN(pszFilename,"MSSQL:",6) )
      64             328 :         return NULL;
      65                 : 
      66               0 :     poDS = new OGRMSSQLSpatialDataSource();
      67                 : 
      68               0 :     if( !poDS->Open( pszFilename, bUpdate, TRUE ) )
      69                 :     {
      70               0 :         delete poDS;
      71               0 :         return NULL;
      72                 :     }
      73                 :     else
      74               0 :         return poDS;
      75                 : }
      76                 : 
      77                 : /************************************************************************/
      78                 : /*                          CreateDataSource()                          */
      79                 : /************************************************************************/
      80                 : 
      81               0 : OGRDataSource *OGRMSSQLSpatialDriver::CreateDataSource( const char * pszName,
      82                 :                                                char **papszOptions )
      83                 : 
      84                 : {
      85               0 :     OGRMSSQLSpatialDataSource   *poDS = new OGRMSSQLSpatialDataSource();
      86                 : 
      87               0 :     if( !EQUALN(pszName,"MSSQL:",6) )
      88               0 :         return NULL;
      89                 : 
      90               0 :     if( !poDS->Open( pszName, TRUE, TRUE ) )
      91                 :     {
      92               0 :         delete poDS;
      93                 :         CPLError( CE_Failure, CPLE_AppDefined, 
      94                 :          "MSSQL Spatial driver doesn't currently support database creation.\n"
      95               0 :                   "Please create database with the Microsoft SQL Server Client Tools." );
      96               0 :         return NULL;
      97                 :     }
      98                 : 
      99               0 :     return poDS;
     100                 : }
     101                 : 
     102                 : /************************************************************************/
     103                 : /*                           TestCapability()                           */
     104                 : /************************************************************************/
     105                 : 
     106               0 : int OGRMSSQLSpatialDriver::TestCapability( const char * pszCap )
     107                 : 
     108                 : {
     109               0 :     if( EQUAL(pszCap,ODrCCreateDataSource) )
     110               0 :         return TRUE;
     111                 :     else
     112               0 :         return FALSE;
     113                 : }
     114                 : 
     115                 : 
     116                 : /************************************************************************/
     117                 : /*                           RegisterOGRMSSQLSpatial()                  */
     118                 : /************************************************************************/
     119                 : 
     120             226 : void RegisterOGRMSSQLSpatial()
     121                 : 
     122                 : {
     123             226 :     if (! GDAL_CHECK_VERSION("OGR/MSSQLSpatial driver"))
     124               0 :         return;
     125             226 :     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRMSSQLSpatialDriver );
     126                 : }
     127                 : 

Generated by: LCOV version 1.7