| QxOrm 1.2.4 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxFunctionMacro.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://www.qxorm.com/
    00004 ** http://sourceforge.net/projects/qxorm/
    00005 ** Original file by Lionel Marty
    00006 **
    00007 ** This file is part of the QxOrm library
    00008 **
    00009 ** This software is provided 'as-is', without any express or implied
    00010 ** warranty. In no event will the authors be held liable for any
    00011 ** damages arising from the use of this software.
    00012 **
    00013 ** GNU Lesser General Public License Usage
    00014 ** This file must be used under the terms of the GNU Lesser
    00015 ** General Public License version 2.1 as published by the Free Software
    00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the
    00017 ** packaging of this file.  Please review the following information to
    00018 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00020 **
    00021 ** If you have questions regarding the use of this file, please contact :
    00022 ** contact@qxorm.com
    00023 **
    00024 ****************************************************************************/
    00025
    00026 #ifndef _QX_FUNCTION_MACRO_H_
    00027 #define _QX_FUNCTION_MACRO_H_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00033 #include <boost/utility/value_init.hpp>
    00034
    00035 #define QX_FUNCTION_CLASS_FCT(className) \
    00036 public: \
    00037 type_fct m_fct; \
    00038 className(type_fct fct) : IxFunction(), m_fct(fct) { ; }; \
    00039 virtual ~className() { ; }; \
    00040 virtual qx_bool invoke(const QString & params = QString(), boost::any * ret = NULL) const \
    00041 { return QxInvokerFct<QString, ! boost::is_same<R, void>::value>::invoke(params, ret, this); } \
    00042 virtual qx_bool invoke(const type_any_params & params, boost::any * ret = NULL) const \
    00043 { return QxInvokerFct<type_any_params, ! boost::is_same<R, void>::value>::invoke(params, ret, this); } \
    00044 virtual qx_bool invoke(void * pOwner, const QString & params = QString(), boost::any * ret = NULL) const \
    00045 { Q_UNUSED(pOwner); Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
    00046 virtual qx_bool invoke(void * pOwner, const type_any_params & params, boost::any * ret = NULL) const \
    00047 { Q_UNUSED(pOwner); Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
    00048 virtual qx_bool isValidFct() const \
    00049 { return (m_fct.empty() ? qx_bool(false, 0, QX_FUNCTION_ERR_EMPTY_FCT) : qx_bool(true)); }
    00050
    00051 #define QX_FUNCTION_CLASS_MEMBER_FCT(className) \
    00052 public: \
    00053 type_fct m_fct; \
    00054 className(type_fct fct) : IxFunction(), m_fct(fct) { ; }; \
    00055 virtual ~className() { ; }; \
    00056 virtual qx_bool invoke(void * pOwner, const QString & params = QString(), boost::any * ret = NULL) const \
    00057 { return QxInvokerFct<QString, ! boost::is_same<R, void>::value>::invoke(pOwner, params, ret, this); } \
    00058 virtual qx_bool invoke(void * pOwner, const type_any_params & params, boost::any * ret = NULL) const \
    00059 { return QxInvokerFct<type_any_params, ! boost::is_same<R, void>::value>::invoke(pOwner, params, ret, this); } \
    00060 virtual qx_bool invoke(const QString & params = QString(), boost::any * ret = NULL) const \
    00061 { Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
    00062 virtual qx_bool invoke(const type_any_params & params, boost::any * ret = NULL) const \
    00063 { Q_UNUSED(params); Q_UNUSED(ret); qAssert(false); return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_INVOKE_CALL); } \
    00064 virtual qx_bool isValidFct() const \
    00065 { return (m_fct.empty() ? qx_bool(false, 0, QX_FUNCTION_ERR_EMPTY_MEMBER_FCT) : qx_bool(true)); }
    00066
    00067 #define QX_FUNCTION_CATCH_AND_RETURN_INVOKE() \
    00068 catch (const std::exception & e) { bValid = qx_bool(false, 0, e.what()); } \
    00069 catch (...) { bValid = qx_bool(false, 0, QX_FUNCTION_ERR_UNKNOWN_ERROR); } \
    00070 if (! bValid) { qDebug("[QxOrm] %s", qPrintable(bValid.getDesc())); qAssert(false); } \
    00071 return bValid;
    00072
    00073 #define QX_FUNCTION_INVOKE_START_WITH_OWNER() \
    00074 if (ret) { (* ret) = boost::any(); } \
    00075 qx_bool bValid = pThis->isValid<T, Owner>(pOwner, params, NULL); \
    00076 if (! bValid) { qDebug("[QxOrm] %s", qPrintable(bValid.getDesc())); qAssert(false); return bValid; }
    00077
    00078 #define QX_FUNCTION_INVOKE_START_WITHOUT_OWNER() \
    00079 if (ret) { (* ret) = boost::any(); } \
    00080 qx_bool bValid = pThis->isValid(params); \
    00081 if (! bValid) { qDebug("[QxOrm] %s", qPrintable(bValid.getDesc())); qAssert(false); return bValid; }
    00082
    00083 #define QX_FUNCTION_FETCH_PARAM(TYPE, VALUE, FCT) \
    00084 boost::value_initialized< TYPE > VALUE; \
    00085 { qx_bool bTmp = qx::function::detail::FCT(params, VALUE, pThis); \
    00086 if (! bTmp) { qDebug("[QxOrm] %s", qPrintable(bTmp.getDesc())); qAssert(false); return bTmp; } }
    00087
    00088 #define QX_FUNCTION_GET_PARAM_TYPE_ANY(PARAMCOUNT) \
    00089 Q_UNUSED(qx_fct); \
    00090 if (params.size() < PARAMCOUNT) { return qx_bool(false, 0, QX_FUNCTION_ERR_NUMBER_PARAMS); } \
    00091 qx_bool bValid = true; \
    00092 try { p = boost::any_cast<P>(params[PARAMCOUNT - 1]); } \
    00093 catch (...) { bValid = qx_bool(false, 0, QString(QX_FUNCTION_ERR_INVALID_PARAM).replace("XXX", QString::number(PARAMCOUNT))); } \
    00094 return bValid;
    00095
    00096 #define QX_FUNCTION_GET_PARAM_TYPE_STRING(PARAMCOUNT) \
    00097 if (! qx_fct) { return qx_bool(false, 0, QX_FUNCTION_ERR_UNKNOWN_ERROR); } \
    00098 QStringList lst = params.split(qx_fct->getSeparator()); \
    00099 if (lst.size() < PARAMCOUNT) { return qx_bool(false, 0, QX_FUNCTION_ERR_NUMBER_PARAMS); } \
    00100 qx_bool bValid = true; \
    00101 try { p = boost::lexical_cast<P>(lst.at(PARAMCOUNT - 1).toStdString()); } \
    00102 catch (...) { bValid = qx_bool(false, 0, QString(QX_FUNCTION_ERR_INVALID_PARAM).replace("XXX", QString::number(PARAMCOUNT))); } \
    00103 return bValid;
    00104
    00105 #define QX_FUNCTION_GET_PARAM_TYPE_STRING_TO_QSTRING(PARAMCOUNT) \
    00106 if (! qx_fct) { return qx_bool(false, 0, QX_FUNCTION_ERR_UNKNOWN_ERROR); } \
    00107 QStringList lst = params.split(qx_fct->getSeparator()); \
    00108 if (lst.size() < PARAMCOUNT) { return qx_bool(false, 0, QX_FUNCTION_ERR_NUMBER_PARAMS); } \
    00109 p = lst.at(PARAMCOUNT - 1); \
    00110 return true;
    00111
    00112 #endif // _QX_FUNCTION_MACRO_H_