提交 f3225970 编写于 作者: M manjaro-xfce

DLL Test Project Added

上级 19707bf4
TEMPLATE = subdirs
SUBDIRS += \
findfoo \
test
#include "findfoo.h"
#include <assert.h>
#include <string>
class Findfoo
{
public:
Findfoo(const std::string & task = "foo");
~Findfoo();
public:
void setTask(const std::string & task);
const std::string & task() const;
long long Find(const std::string & rawStr);
private:
std::string m_task = "foo";
};
Findfoo::Findfoo(const std::string & task)
:m_task(task)
{
}
Findfoo::~Findfoo()
{
}
void Findfoo::setTask(const std::string & task)
{
m_task = task;
}
const std::string & Findfoo::task() const
{
return m_task;
}
long long Findfoo::Find(const std::string & rawStr)
{
return rawStr.find(m_task);
}
//-----------
FINDFOO_EXPORT FFHANDLE FOOCALL ff_init_task(const char * task)
{
Findfoo * f = new Findfoo(task);
return (FFHANDLE) f;
}
FINDFOO_EXPORT void FOOCALL ff_reset_task(FFHANDLE h, const char * task)
{
Findfoo * f = reinterpret_cast<Findfoo *>(h);
assert(f);
f->setTask(task);
}
FINDFOO_EXPORT const char * FOOCALL ff_get_task(FFHANDLE h)
{
Findfoo * f = reinterpret_cast<Findfoo *>(h);
assert(f);
return f->task().c_str();
}
FINDFOO_EXPORT long long FOOCALL ff_find(FFHANDLE h, const char * rawStr)
{
Findfoo * f = reinterpret_cast<Findfoo *>(h);
assert(f);
return f->Find(rawStr);
}
FINDFOO_EXPORT void FOOCALL ff_fini_task(FFHANDLE h)
{
Findfoo * f = reinterpret_cast<Findfoo *>(h);
if (f)
delete f;
}
#ifndef FINDFOO_H
#define FINDFOO_H
#include "findfoo_global.h"
#ifdef __cplusplus
extern "C"{
#endif
FINDFOO_EXPORT FFHANDLE FOOCALL ff_init_task (const char * task);
FINDFOO_EXPORT void FOOCALL ff_reset_task (FFHANDLE h , const char * task);
FINDFOO_EXPORT const char * FOOCALL ff_get_task (FFHANDLE h );
FINDFOO_EXPORT long long FOOCALL ff_find (FFHANDLE h , const char * rawStr);
FINDFOO_EXPORT void FOOCALL ff_fini_task (FFHANDLE h );
#ifdef __cplusplus
}
#endif
#endif // FINDFOO_H
CONFIG -= qt
TEMPLATE = lib
DEFINES += FINDFOO_LIBRARY
DESTDIR = $$OUT_PWD/../bin
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
findfoo.cpp
HEADERS += \
findfoo_global.h \
findfoo.h
#ifndef FINDFOO_GLOBAL_H
#define FINDFOO_GLOBAL_H
#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# define Q_DECL_EXPORT __declspec(dllexport)
# define Q_DECL_IMPORT __declspec(dllimport)
# define FOOCALL __stdcall
#else
# define Q_DECL_EXPORT __attribute__((visibility("default")))
# define Q_DECL_IMPORT __attribute__((visibility("default")))
# define FOOCALL
#endif
#if defined(FINDFOO_LIBRARY)
# define FINDFOO_EXPORT Q_DECL_EXPORT
#else
# define FINDFOO_EXPORT Q_DECL_IMPORT
#endif
#define FFHANDLE void *
#endif // FINDFOO_GLOBAL_H
#include <iostream>
#include <cassert>
#include "findfoo.h"
using namespace std;
int main()
{
FFHANDLE h = ff_init_task("foobar");
assert(h);
cout << "Task string:" << ff_get_task(h) << endl;
cout << "Input String:";
std::string strRaw;
cin >> strRaw;
cout << ff_find(h,strRaw.c_str());
//Delete
ff_fini_task(h);
h = nullptr;
return 0;
}
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
DESTDIR = $$OUT_PWD/../bin
INCLUDEPATH += ../findfoo
if (*static*){
message($$QMAKESPEC);
LIBS += -lfindfoo.dll -L$$DESTDIR
}
else{
LIBS += -lfindfoo -L$$DESTDIR
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册