LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/vfk - vfkpropertydefn.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 26 25 96.2 %
Date: 2011-12-18 Functions: 4 2 50.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: vfkpropertydefn.cpp 18452 2010-01-07 15:18:49Z martinl $
       3                 :  *
       4                 :  * Project:  VFK Reader - Data block property definition
       5                 :  * Purpose:  Implements VFKPropertyDefn class.
       6                 :  * Author:   Martin Landa, landa.martin gmail.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2009-2010, 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                 : #include "vfkreader.h"
      33                 : #include "vfkreaderp.h"
      34                 : 
      35                 : #include "cpl_conv.h"
      36                 : #include "cpl_error.h"
      37                 : 
      38                 : /*!
      39                 :   \brief VFKPropertyDefn constructor
      40                 : 
      41                 :   \param pszName property name
      42                 :   \param pszType property type (original, string)
      43                 : */
      44             575 : VFKPropertyDefn::VFKPropertyDefn(const char *pszName, const char *pszType)
      45                 : {
      46                 :     char *poChar, *poWidth, *pszWidth;
      47                 :     int   nLength;
      48                 : 
      49             575 :     m_pszName = CPLStrdup(pszName);
      50             575 :     m_pszType = CPLStrdup(pszType);
      51                 : 
      52             575 :     poWidth = poChar = m_pszType + 1;
      53             575 :     for (nLength = 0; *poChar && *poChar != '.'; nLength++, poChar++)
      54                 :   ;
      55                 : 
      56             575 :     m_nPrecision = 0;
      57                 :     /* type */
      58             575 :     if (*m_pszType == 'N') {
      59             335 :   if (*poChar == '.') {
      60              30 :       m_eFType = OFTReal;
      61              30 :       m_nPrecision = atoi(poChar+1);
      62                 :   }
      63                 :   else {
      64             305 :       m_eFType = OFTInteger;
      65                 :   }
      66                 :     }
      67             240 :     else if (*m_pszType == 'T') {
      68                 :   /* string */
      69             141 :   m_eFType = OFTString;
      70                 :     }
      71              99 :     else if (*m_pszType == 'D') {
      72                 :   /* date */
      73              99 :   m_eFType = OFTDateTime;
      74                 :     }
      75                 :     else {
      76                 :   /* unknown - string */
      77               0 :   m_eFType = OFTString;
      78                 :     }
      79                 : 
      80                 :     /* width */
      81             575 :     pszWidth = (char *) CPLMalloc(nLength+1);
      82             575 :     strncpy(pszWidth, poWidth, nLength);
      83             575 :     pszWidth[nLength] = '\0';
      84                 :     
      85             575 :     m_nWidth  = atoi(pszWidth);
      86             575 :     CPLFree(pszWidth);
      87             575 : }
      88                 : 
      89                 : /*!
      90                 :   \brief VFKPropertyDefn destructor
      91                 : */
      92             575 : VFKPropertyDefn::~VFKPropertyDefn()
      93                 : {
      94             575 :     CPLFree(m_pszName);
      95             575 :     CPLFree(m_pszType);
      96             575 : }

Generated by: LCOV version 1.7