diff --git a/findfoo/findfoo.pro b/findfoo/findfoo.pro new file mode 100644 index 0000000000000000000000000000000000000000..e63ef51e19f07cbd7eb562870e343581bf4d12eb --- /dev/null +++ b/findfoo/findfoo.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs +SUBDIRS += \ + findfoo \ + test + diff --git a/findfoo/findfoo/findfoo.cpp b/findfoo/findfoo/findfoo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9cae85de3062bbf323a09cc9aa598e79cd132b79 --- /dev/null +++ b/findfoo/findfoo/findfoo.cpp @@ -0,0 +1,76 @@ +#include "findfoo.h" +#include +#include +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(h); + assert(f); + f->setTask(task); + +} + +FINDFOO_EXPORT const char * FOOCALL ff_get_task(FFHANDLE h) +{ + Findfoo * f = reinterpret_cast(h); + assert(f); + return f->task().c_str(); +} + +FINDFOO_EXPORT long long FOOCALL ff_find(FFHANDLE h, const char * rawStr) +{ + Findfoo * f = reinterpret_cast(h); + assert(f); + return f->Find(rawStr); +} + +FINDFOO_EXPORT void FOOCALL ff_fini_task(FFHANDLE h) +{ + Findfoo * f = reinterpret_cast(h); + if (f) + delete f; +} diff --git a/findfoo/findfoo/findfoo.h b/findfoo/findfoo/findfoo.h new file mode 100644 index 0000000000000000000000000000000000000000..c88e7c756d1466ed0077fa1d0190bfc2b0cc1538 --- /dev/null +++ b/findfoo/findfoo/findfoo.h @@ -0,0 +1,15 @@ +#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 diff --git a/findfoo/findfoo/findfoo.pro b/findfoo/findfoo/findfoo.pro new file mode 100644 index 0000000000000000000000000000000000000000..0393e60c919525b8f2967fd01bcc904b1ae58cb5 --- /dev/null +++ b/findfoo/findfoo/findfoo.pro @@ -0,0 +1,19 @@ +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 + + diff --git a/findfoo/findfoo/findfoo_global.h b/findfoo/findfoo/findfoo_global.h new file mode 100644 index 0000000000000000000000000000000000000000..14c8b48b657c95d7df18802b732d804a700069d4 --- /dev/null +++ b/findfoo/findfoo/findfoo_global.h @@ -0,0 +1,22 @@ +#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 diff --git a/findfoo/test/main.cpp b/findfoo/test/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..34eb39a3b28c9616d7e3cd82023fe07b22102e3c --- /dev/null +++ b/findfoo/test/main.cpp @@ -0,0 +1,19 @@ +#include +#include +#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; +} diff --git a/findfoo/test/test.pro b/findfoo/test/test.pro new file mode 100644 index 0000000000000000000000000000000000000000..eeab07032b307cf23d98b325878f062667de897c --- /dev/null +++ b/findfoo/test/test.pro @@ -0,0 +1,17 @@ +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 +}