-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic.cpp
39 lines (35 loc) · 847 Bytes
/
logic.cpp
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
38
//
// Created by viking on 7/11/18.
// Logic operators for queries
#include <sqlsetup.h>
const auto and_(const QString &conditions)
{
auto cond=conditions.split(",",QString::SkipEmptyParts);
auto ret=cond.at(0);
cond.removeFirst();
if (cond.length()>1) ret="( "+ret;
foreach(auto c, cond)
{
ret+=" AND "+c;
}
if (cond.length()>1) ret=ret+" )";
return ret;
}
const auto or_(const QString &conditions)
{
auto cond=conditions.split(",",QString::SkipEmptyParts);
auto ret=cond.at(0);
cond.removeFirst();
if (cond.length()>1) ret="( "+ret;
foreach(auto c, cond)
{
ret+=" OR "+c;
}
if (cond.length()>1) ret=ret+" )";
return ret;
}
const auto not_(const QString &conditions)
{
auto ret = " NOT "+conditions;
return ret;
}