字符串定义
#define d1 "b"
拼接
#define d2 "aaa"d1
参数拼接
#define da(x,y,c,d,e) x##y##c##d##e
#define db da("a","b","c","d","e")
// 拼接1
#define da(x,y,c,d,e) x##y##c##d##e
#define dba(x) da(x,"b","c","d","e")
#define dbb dba("1")"a"dba("1")
//高级转换
//数字转字符串
#define itos1(x) #x
#define canshu itos1(1)
#define sqltrans_sql_all "select (case when t.status = "canshu" then 'bbb' else 'aaa' end ) as 'aaa' from tablea"
// 带枚举转换
#define itos(x) QString::number(x)
#define sqltrans_task_types itos(e_task_status_closed)
// 枚举转换再相加
#define def_test1 "a"
#define is(x) QString::number(x)
#define cs(x) QString(x)
#define sqltrans_task_types_a is(e_task_status_closed)
#define sqltrans_task_types is(e_task_status_closed)+cs(def_test1)
// 终极玩法
// test sql
//#define sqltrans_sql_all "select (case when t.status = 1 then 'bbb' else 'aaa' end ) as 'aaa' from tablea"
#define is(x) QString::number(x)
#define cs(x) QString(x)
#define canshu itos1(e_task_status_closed)
#define sqltrans_task_types cs("(case when t.Type = ") + is(e_task_status_closed) + cs(" then '"task_types_normal"' when t.Type = ") + is(e_task_status_closed)+ cs(" then '"task_types_develop"' else '"SQL_NULL "' end ) as '"task_types "' ")
// 判断玩法
#define sql_query_task_filter_project_type_title_sd_ed(a,b,c,d,e) \
do{\
QString sql;\
if(a==ERR) \
;\
else \
c+d+e;\
;}while(0);
#endif // CLIENTSQL_H
// 全代码玩法
#define sql_query_task_filter_project_type_title_sd_ed(a,b,c,d,e) \
do{\
QString sql = CtoS(sql_query_task_filter) + CtoS(" where t.Title LIKE '%") + CtoS(c) + CtoS("%' AND t.BuildDate >= '") + CtoS(d) + CtoS("' AND t.EndDate <= '") + CtoS(e) + CtoS("' ");\
if (a!=e_task_projects_bx) \
sql += CtoS(" AND t.ProjectID = ") + CtoS(a);\
else if (b!=e_task_types_bx) \
sql += CtoS(" AND t.Type = ") + CtoS(b);\
m_pModel->setQuery(sql);\
qDebug() << sql;\
}while(0)