• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tstack / lnav / 11872214087-1756

16 Nov 2024 06:12PM UTC coverage: 70.243% (+0.5%) from 69.712%
11872214087-1756

push

github

tstack
[build] disable regex101

46266 of 65866 relevant lines covered (70.24%)

467515.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/src/sqlitepp.hh
1
/**
2
 * Copyright (c) 2022, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * @file sqlitepp.hh
30
 */
31

32
#ifndef lnav_sqlitepp_hh
33
#define lnav_sqlitepp_hh
34

35
#include <string>
36

37
#include <sqlite3.h>
38

39
#include "base/auto_mem.hh"
40
#include "base/intern_string.hh"
41
#include "base/types.hh"
42

43
/* XXX figure out how to do this with the template */
44
void sqlite_close_wrapper(void* mem);
45

46
using auto_sqlite3 = auto_mem<sqlite3, sqlite_close_wrapper>;
47

48
namespace sqlitepp {
49

50
inline auto_mem<char>
51
quote(const std::optional<std::string>& str)
32✔
52
{
53
    auto_mem<char> retval(sqlite3_free);
32✔
54

55
    if (str) {
32✔
56
        retval = sqlite3_mprintf("%Q", str.value().c_str());
21✔
57
    } else {
58
        retval = sqlite3_mprintf("NULL");
11✔
59
    }
60

61
    return retval;
32✔
62
}
×
63

64
extern const char* ERROR_PREFIX;
65

66
struct bind_visitor {
67
    bind_visitor(sqlite3_stmt* stmt, int index) : bv_stmt(stmt), bv_index(index)
70✔
68
    {
69
    }
70✔
70

71
    void operator()(const std::string& str) const
48✔
72
    {
73
        sqlite3_bind_text(this->bv_stmt,
48✔
74
                          this->bv_index,
48✔
75
                          str.c_str(),
76
                          str.size(),
48✔
77
                          SQLITE_TRANSIENT);
78
    }
48✔
79

80
    void operator()(const string_fragment& str) const
×
81
    {
82
        sqlite3_bind_text(this->bv_stmt,
×
83
                          this->bv_index,
×
84
                          str.data(),
85
                          str.length(),
86
                          SQLITE_TRANSIENT);
87
    }
88

89
    void operator()(null_value_t) const
6✔
90
    {
91
        sqlite3_bind_null(this->bv_stmt, this->bv_index);
6✔
92
    }
6✔
93

94
    void operator()(int64_t value) const
15✔
95
    {
96
        sqlite3_bind_int64(this->bv_stmt, this->bv_index, value);
15✔
97
    }
15✔
98

99
    void operator()(double value) const
1✔
100
    {
101
        sqlite3_bind_double(this->bv_stmt, this->bv_index, value);
1✔
102
    }
1✔
103

104
    sqlite3_stmt* bv_stmt;
105
    int bv_index;
106
};
107

108
}  // namespace sqlitepp
109

110
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc