aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/sqlite/sqlitewritestatement.h
blob: 70ef8eb68aac3eff8cc402d2013338007b7ef093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "sqlitebasestatement.h"

namespace Sqlite {
template<int BindParameterCount = 0>
class WriteStatement : protected StatementImplementation<BaseStatement, -1, BindParameterCount>
{
    using Base = StatementImplementation<BaseStatement, -1, BindParameterCount>;

public:
    WriteStatement(Utils::SmallStringView sqlStatement, Database &database)
        : Base(sqlStatement, database)
    {
        checkIsWritableStatement();
        Base::checkBindingParameterCount(BindParameterCount);
        Base::checkColumnCount(0);
    }

    using Base::database;
    using Base::execute;
    using Base::write;

protected:
    void checkIsWritableStatement()
    {
        if (Base::isReadOnlyStatement())
            throw NotWriteSqlStatement(
                "SqliteStatement::SqliteWriteStatement: is not a writable statement!");
    }
};

} // namespace Sqlite