extern "C"{ char* result(char* );}char* result(char* a){ return a;}
#include <iostrem>
#include <QtCore/QtGlobal>#include <math.h>#ifdef Q_OS_WIN # if defined( QT_BUILD_MATH_LIB )# define Q_MATH_EXPORT __declspec(dllexport)# else # define Q_MATH_EXPORT __declspec(dllimport)# endif#else # define Q_MATH_EXPORT#endif extern "C" Q_MATH_EXPORT double ib_udf_round_to(double *x, int *y){ double p = pow(10.0, *y); return qRound64(*x * p) / p;}
...win32 { DEFINES += QT_BUILD_MATH_LIB}...
QString str;
#include <string>std::string str;
QByteArray::toString()
extern "C" __declspec(dllexport) char* ib_udf_createUUID(){ char *p; p = QUuid::createUuid().toString().toLatin1().data(); return p;}
#include <QtCore/QtGlobal>#include <QUuid>#ifdef Q_OS_WIN# if defined( QT_BUILD_MATH_LIB )# define Q_MATH_EXPORT __declspec(dllexport)# else# define Q_MATH_EXPORT __declspec(dllimport)# endif#else# define Q_MATH_EXPORT#endifextern "C" __declspec(dllexport) char* ib_udf_createUUID(){ char *p; p = QUuid::createUuid().toString().toLatin1().data(); return p;}
DECLARE EXTERNAL FUNCTION UDFRETURNS CSTRING(254) FREE_ITENTRY_POINT 'ib_udf_createUUID' MODULE_NAME 'crqphudf';
select UDF() from Object
#include <QtCore/QtGlobal>#include <QtCore/QUuid>#include <ib_util.h>extern "C" __declspec(dllexport) char* ib_udf_createUUID(){ char *p, *buf; p = QUuid::createUuid().toString().toLatin1().data(); buf = (char*) ib_util_malloc(64); затем перегоняешь из p в buf return buf;}
#include <QtCore/QtGlobal>#include <QDebug>extern "C" __declspec(dllexport) char* tostring(char* str){ QByteArray data(str); data = data.toBase64(); char *p = new char(); p = data.data(); qDebug() << p; return p;}
QT -= guiQT += coreTARGET = crqphudfTEMPLATE = libDEFINES += CRQPHUDF_LIBRARYSOURCES += crqphudf.cppHEADERS += CONFIG += release
typedef char* (*toBase)(char *); toBase tobase = (toBase) QLibrary::resolve("crqphudf","tostring"); char* base = tobase("qwerty"); qDebug() << "key" << base;
qDebug() << p;
qDebug() << "key" << base;
char *p = new char(); p = str; return p;