LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/vfk - vfkproperty.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 22 28 78.6 %
Date: 2024-05-04 12:52:34 Functions: 7 9 77.8 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  VFK Reader - Property definition
       4             :  * Purpose:  Implements VFKProperty class.
       5             :  * Author:   Martin Landa, landa.martin gmail.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2009-2010, Martin Landa <landa.martin gmail.com>
       9             :  *
      10             :  * Permission is hereby granted, free of charge, to any person
      11             :  * obtaining a copy of this software and associated documentation
      12             :  * files (the "Software"), to deal in the Software without
      13             :  * restriction, including without limitation the rights to use, copy,
      14             :  * modify, merge, publish, distribute, sublicense, and/or sell copies
      15             :  * of the Software, and to permit persons to whom the Software is
      16             :  * furnished to do so, subject to the following conditions:
      17             :  *
      18             :  * The above copyright notice and this permission notice shall be
      19             :  * included in all copies or substantial portions of the Software.
      20             :  *
      21             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      22             :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      23             :  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      24             :  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
      25             :  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
      26             :  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
      27             :  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      28             :  * SOFTWARE.
      29             :  ****************************************************************************/
      30             : 
      31             : #include "vfkreader.h"
      32             : #include "vfkreaderp.h"
      33             : 
      34             : #include "cpl_conv.h"
      35             : #include "cpl_error.h"
      36             : 
      37             : /*!
      38             :   \brief Set VFK property (null)
      39             : */
      40        4005 : VFKProperty::VFKProperty() : m_bIsNull(true), m_iValue(0), m_dValue(0.0)
      41             : {
      42        4005 : }
      43             : 
      44             : /*!
      45             :   \brief Set VFK property (integer)
      46             : */
      47        2205 : VFKProperty::VFKProperty(int iValue)
      48        2205 :     : m_bIsNull(false), m_iValue(iValue), m_dValue(0.0)
      49             : {
      50        2205 : }
      51             : 
      52             : /*!
      53             :   \brief Set VFK property (big integer)
      54             : */
      55        3870 : VFKProperty::VFKProperty(GIntBig iValue)
      56        3870 :     : m_bIsNull(false), m_iValue(iValue), m_dValue(0.0)
      57             : {
      58        3870 : }
      59             : 
      60             : /*!
      61             :   \brief Set VFK property (double)
      62             : */
      63         390 : VFKProperty::VFKProperty(double dValue)
      64         390 :     : m_bIsNull(false), m_iValue(0), m_dValue(dValue)
      65             : {
      66         390 : }
      67             : 
      68             : /*!
      69             :   \brief Set VFK property (string)
      70             : */
      71        1320 : VFKProperty::VFKProperty(const char *pszValue)
      72             :     : m_bIsNull(false), m_iValue(0), m_dValue(0.0),
      73        1320 :       m_strValue(nullptr != pszValue ? pszValue : "")
      74             : {
      75        1320 : }
      76             : 
      77             : /*!
      78             :   \brief Set VFK property (string)
      79             : */
      80           0 : VFKProperty::VFKProperty(CPLString const &strValue)
      81           0 :     : m_bIsNull(false), m_iValue(0), m_dValue(0.0), m_strValue(strValue)
      82             : {
      83           0 : }
      84             : 
      85             : /*!
      86             :   \brief VFK property destructor
      87             : */
      88       22710 : VFKProperty::~VFKProperty()
      89             : {
      90       22710 : }
      91             : 
      92             : /*!
      93             :   \brief Get string property
      94             : 
      95             :   \param escape true to escape characters for SQL
      96             : 
      97             :   \return string buffer
      98             : */
      99        1320 : const char *VFKProperty::GetValueS(bool escape) const
     100             : {
     101        1320 :     if (!escape)
     102           0 :         return m_strValue.c_str();
     103             : 
     104        2640 :     CPLString strValue(m_strValue);
     105        1320 :     size_t ipos = 0;
     106        1320 :     while (std::string::npos != (ipos = strValue.find("'", ipos)))
     107             :     {
     108           0 :         strValue.replace(ipos, 1, "\'\'", 2);
     109           0 :         ipos += 2;
     110             :     }
     111             : 
     112        1320 :     return CPLSPrintf("%s", strValue.c_str());
     113             : }

Generated by: LCOV version 1.14