Coverage Report

Created: 2026-05-16 08:20

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
285k
VFKProperty::VFKProperty() : m_bIsNull(true), m_iValue(0), m_dValue(0.0)
23
285k
{
24
285k
}
25
26
/*!
27
  \brief Set VFK property (integer)
28
*/
29
VFKProperty::VFKProperty(int iValue)
30
79.5k
    : m_bIsNull(false), m_iValue(iValue), m_dValue(0.0)
31
79.5k
{
32
79.5k
}
33
34
/*!
35
  \brief Set VFK property (big integer)
36
*/
37
VFKProperty::VFKProperty(GIntBig iValue)
38
117k
    : m_bIsNull(false), m_iValue(iValue), m_dValue(0.0)
39
117k
{
40
117k
}
41
42
/*!
43
  \brief Set VFK property (double)
44
*/
45
VFKProperty::VFKProperty(double dValue)
46
20.0k
    : m_bIsNull(false), m_iValue(0), m_dValue(dValue)
47
20.0k
{
48
20.0k
}
49
50
/*!
51
  \brief Set VFK property (string)
52
*/
53
VFKProperty::VFKProperty(const char *pszValue)
54
113k
    : m_bIsNull(false), m_iValue(0), m_dValue(0.0),
55
113k
      m_strValue(nullptr != pszValue ? pszValue : "")
56
113k
{
57
113k
}
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.49M
{
72
1.49M
}
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
113k
{
83
113k
    if (!escape)
84
0
        return m_strValue.c_str();
85
86
113k
    CPLString strValue(m_strValue);
87
113k
    size_t ipos = 0;
88
142k
    while (std::string::npos != (ipos = strValue.find("'", ipos)))
89
28.7k
    {
90
28.7k
        strValue.replace(ipos, 1, "\'\'", 2);
91
28.7k
        ipos += 2;
92
28.7k
    }
93
94
113k
    return CPLSPrintf("%s", strValue.c_str());
95
113k
}