QxOrm
1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxFunctionMacro.h
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** https://www.qxorm.com/
4
** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5
**
6
** This file is part of the QxOrm library
7
**
8
** This software is provided 'as-is', without any express or implied
9
** warranty. In no event will the authors be held liable for any
10
** damages arising from the use of this software
11
**
12
** Commercial Usage
13
** Licensees holding valid commercial QxOrm licenses may use this file in
14
** accordance with the commercial license agreement provided with the
15
** Software or, alternatively, in accordance with the terms contained in
16
** a written agreement between you and Lionel Marty
17
**
18
** GNU General Public License Usage
19
** Alternatively, this file may be used under the terms of the GNU
20
** General Public License version 3.0 as published by the Free Software
21
** Foundation and appearing in the file 'license.gpl3.txt' included in the
22
** packaging of this file. Please review the following information to
23
** ensure the GNU General Public License version 3.0 requirements will be
24
** met : http://www.gnu.org/copyleft/gpl.html
25
**
26
** If you are unsure which license is appropriate for your use, or
27
** if you have questions regarding the use of this file, please contact :
28
** contact@qxorm.com
29
**
30
****************************************************************************/
31
32
#ifndef _QX_FUNCTION_MACRO_H_
33
#define _QX_FUNCTION_MACRO_H_
34
35
#ifdef _MSC_VER
36
#pragma once
37
#endif
38
39
#include <
QxConvert/QxConvert.h
>
40
41
#define QX_FUNCTION_CLASS_FCT(className) \
42
public: \
43
type_fct m_fct; \
44
className(type_fct fct) : IxFunction(), m_fct(fct) { ; }; \
45
virtual ~className() { ; }; \
46
virtual qx_bool invoke(const QString & params = QString(), qx::any * ret = NULL) const \
47
{ return QxInvokerFct<QString, ! std::is_same<R, void>::value>::invoke(params, ret, this); } \
48
virtual qx_bool invoke(const type_any_params & params, qx::any * ret = NULL) const \
49
{ return QxInvokerFct<type_any_params, ! std::is_same<R, void>::value>::invoke(params, ret, this); } \
50
virtual qx_bool invoke(void * pOwner, const QString & params = QString(), qx::any * ret = NULL) const \
51
{ Q_UNUSED(pOwner); Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
52
virtual qx_bool invoke(void * pOwner, const type_any_params & params, qx::any * ret = NULL) const \
53
{ Q_UNUSED(pOwner); Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
54
virtual qx_bool isValidFct() const \
55
{ return ((! m_fct) ? qx_bool(false, 0, QX_FUNCTION_ERR_EMPTY_FCT) : qx_bool(true)); }
56
57
#define QX_FUNCTION_CLASS_MEMBER_FCT(className) \
58
public: \
59
type_fct m_fct; \
60
className(type_fct fct) : IxFunction(), m_fct(fct) { ; }; \
61
virtual ~className() { ; }; \
62
virtual qx_bool invoke(void * pOwner, const QString & params = QString(), qx::any * ret = NULL) const \
63
{ return QxInvokerFct<QString, ! std::is_same<R, void>::value>::invoke(pOwner, params, ret, this); } \
64
virtual qx_bool invoke(void * pOwner, const type_any_params & params, qx::any * ret = NULL) const \
65
{ return QxInvokerFct<type_any_params, ! std::is_same<R, void>::value>::invoke(pOwner, params, ret, this); } \
66
virtual qx_bool invoke(const QString & params = QString(), qx::any * ret = NULL) const \
67
{ Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
68
virtual qx_bool invoke(const type_any_params & params, qx::any * ret = NULL) const \
69
{ Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
70
virtual qx_bool isValidFct() const \
71
{ return ((! m_fct) ? qx_bool(false, 0, QX_FUNCTION_ERR_EMPTY_MEMBER_FCT) : qx_bool(true)); }
72
73
#define QX_FUNCTION_CATCH_AND_RETURN_INVOKE() \
74
catch (const std::exception & e) { bValid = qx_bool(false, 0, e.what()); } \
75
catch (...) { bValid = qx_bool(false, 0, QX_FUNCTION_ERR_UNKNOWN_ERROR); } \
76
if (! bValid) { QString sMsgDebug = bValid.getDesc(); qDebug("[QxOrm] %s", qPrintable(sMsgDebug)); qAssert(false); } \
77
return bValid;
78
79
#define QX_FUNCTION_INVOKE_START_WITH_OWNER() \
80
if (ret) { (* ret) = qx::any(); } \
81
qx_bool bValid = pThis->isValid<T, Owner>(pOwner, params, NULL); \
82
if (! bValid) { QString sMsgDebug = bValid.getDesc(); qDebug("[QxOrm] %s", qPrintable(sMsgDebug)); qAssert(false); return bValid; }
83
84
#define QX_FUNCTION_INVOKE_START_WITHOUT_OWNER() \
85
if (ret) { (* ret) = qx::any(); } \
86
qx_bool bValid = pThis->isValid(params); \
87
if (! bValid) { QString sMsgDebug = bValid.getDesc(); qDebug("[QxOrm] %s", qPrintable(sMsgDebug)); qAssert(false); return bValid; }
88
89
#define QX_FUNCTION_FETCH_PARAM(TYPE, VALUE, FCT) \
90
typename std::remove_const< TYPE >::type VALUE; \
91
{ qx_bool bTmp = qx::function::detail::FCT(params, VALUE, pThis); \
92
if (! bTmp) { QString sMsgDebug = bTmp.getDesc(); qDebug("[QxOrm] %s", qPrintable(sMsgDebug)); qAssert(false); return bTmp; } }
93
94
#define QX_FUNCTION_GET_PARAM_TYPE_ANY(PARAMCOUNT) \
95
Q_UNUSED(qx_fct); \
96
if (params.size() < PARAMCOUNT) { return qx_bool(false, 0, QX_FUNCTION_ERR_NUMBER_PARAMS); } \
97
qx_bool bValid = true; \
98
try { p = qx::any_cast<P>(params[PARAMCOUNT - 1]); } \
99
catch (...) { bValid = qx_bool(false, 0, QString(QX_FUNCTION_ERR_INVALID_PARAM).replace("XXX", QString::number(PARAMCOUNT))); } \
100
return bValid;
101
102
#define QX_FUNCTION_GET_PARAM_TYPE_STRING(PARAMCOUNT) \
103
if (! qx_fct) { return qx_bool(false, 0, QX_FUNCTION_ERR_UNKNOWN_ERROR); } \
104
QStringList lst = params.split(qx_fct->getSeparator()); \
105
if (lst.size() < PARAMCOUNT) { return qx_bool(false, 0, QX_FUNCTION_ERR_NUMBER_PARAMS); } \
106
qx_bool bValid = true; \
107
try { bValid = qx::cvt::from_string(lst.at(PARAMCOUNT - 1), p); } \
108
catch (...) { bValid = qx_bool(false, 0, QString(QX_FUNCTION_ERR_INVALID_PARAM).replace("XXX", QString::number(PARAMCOUNT))); } \
109
return bValid;
110
111
#define QX_FUNCTION_GET_PARAM_TYPE_STRING_TO_QSTRING(PARAMCOUNT) \
112
if (! qx_fct) { return qx_bool(false, 0, QX_FUNCTION_ERR_UNKNOWN_ERROR); } \
113
QStringList lst = params.split(qx_fct->getSeparator()); \
114
if (lst.size() < PARAMCOUNT) { return qx_bool(false, 0, QX_FUNCTION_ERR_NUMBER_PARAMS); } \
115
p = lst.at(PARAMCOUNT - 1); \
116
return true;
117
118
#endif
// _QX_FUNCTION_MACRO_H_
QxConvert.h
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
include
QxFunction
QxFunctionMacro.h
Generated on Wed Jul 24 2024 21:08:17 for QxOrm by
1.11.0