aboutsummaryrefslogtreecommitdiff
path: root/include/odhtdb/sql/Sql.hpp
blob: 6c78360bdab558a0867c9acf949515a934ec6d64 (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
37
#pragma once

#include "../DataView.hpp"

class sqlite3;
class sqlite3_stmt;

namespace odhtdb
{
    class SqlArg
    {
    public:
        enum class Type : u8
        {
            DATA_VIEW,
            INT,
            INT64,
            UINT64
        };
        
        SqlArg(const DataView &data) : dataView(data), type(Type::DATA_VIEW) {}
        SqlArg(int data) : integer(data), type(Type::INT) {}
        SqlArg(i64 data) : integer64(data), type(Type::INT64) {}
        SqlArg(u64 data) : uinteger64(data), type(Type::UINT64) {}
        
        int bind(sqlite3_stmt *stmt, int paramIndex) const;
    private:
        union
        {
            const DataView dataView;
            const int integer;
            const i64 integer64;
            const u64 uinteger64;
        };
        const Type type;
    };
}