Coverage Report

Created: 2025-12-03 08:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/ogr/ogrsf_frmts/vfk/vfkproperty.cpp
Line
Count
Source
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
 * SPDX-License-Identifier: MIT
11
 ****************************************************************************/
12
13
#include "vfkreader.h"
14
#include "vfkreaderp.h"
15
16
#include "cpl_conv.h"
17
#include "cpl_error.h"
18
19
/*!
20
  \brief Set VFK property (null)
21
*/
22
233k
VFKProperty::VFKProperty() : m_bIsNull(true), m_iValue(0), m_dValue(0.0)
23
233k
{
24
233k
}
25
26
/*!
27
  \brief Set VFK property (integer)
28
*/
29
VFKProperty::VFKProperty(int iValue)
30
61.4k
    : m_bIsNull(false), m_iValue(iValue), m_dValue(0.0)
31
61.4k
{
32
61.4k
}
33
34
/*!
35
  \brief Set VFK property (big integer)
36
*/
37
VFKProperty::VFKProperty(GIntBig iValue)
38
85.3k
    : m_bIsNull(false), m_iValue(iValue), m_dValue(0.0)
39
85.3k
{
40
85.3k
}
41
42
/*!
43
  \brief Set VFK property (double)
44
*/
45
VFKProperty::VFKProperty(double dValue)
46
20.7k
    : m_bIsNull(false), m_iValue(0), m_dValue(dValue)
47
20.7k
{
48
20.7k
}
49
50
/*!
51
  \brief Set VFK property (string)
52
*/
53
VFKProperty::VFKProperty(const char *pszValue)
54
83.4k
    : m_bIsNull(false), m_iValue(0), m_dValue(0.0),
55
83.4k
      m_strValue(nullptr != pszValue ? pszValue : "")
56
83.4k
{
57
83.4k
}
58
59
/*!
60
  \brief Set VFK property (string)
61
*/
62
VFKProperty::VFKProperty(CPLString const &strValue)
63
0
    : m_bIsNull(false), m_iValue(0), m_dValue(0.0), m_strValue(strValue)
64
0
{
65
0
}
66
67
/*!
68
  \brief VFK property destructor
69
*/
70
VFKProperty::~VFKProperty()
71
1.25M
{
72
1.25M
}
73
74
/*!
75
  \brief Get string property
76
77
  \param escape true to escape characters for SQL
78
79
  \return string buffer
80
*/
81
const char *VFKProperty::GetValueS(bool escape) const
82
83.4k
{
83
83.4k
    if (!escape)
84
0
        return m_strValue.c_str();
85
86
83.4k
    CPLString strValue(m_strValue);
87
83.4k
    size_t ipos = 0;
88
107k
    while (std::string::npos != (ipos = strValue.find("'", ipos)))
89
23.7k
    {
90
23.7k
        strValue.replace(ipos, 1, "\'\'", 2);
91
23.7k
        ipos += 2;
92
23.7k
    }
93
94
83.4k
    return CPLSPrintf("%s", strValue.c_str());
95
83.4k
}