#ifndef CL_SMOKE_QT_QLIST_H #define CL_SMOKE_QT_QLIST_H #include "cl_smoke_qt.h" #include /** @file */ /** Defines a C wrapper for the QList<@a TYPE>. * @param TYPE the type of the elements of the QList */ #define DEFINE_QLIST_WRAPPER(TYPE) \ DEFINE_QLIST_WRAPPER_3(TYPE, TYPE, VALUE) /** Defines a C wrapper for the QList<@a TYPE*>, * where @a TYPE is the of the pointer. * * @param NAME the name used for the wrapper functions. * @param TYPE the type of the elements */ #define DEFINE_QLIST_WRAPPER_PTR(TYPE) \ DEFINE_QLIST_WRAPPER_3(TYPE, TYPE*, PTR) /** @internal */ #define DEFINE_QLIST_WRAPPER_3(NAME, TYPE, PTR_VALUE) \ DEFINE_QLIST_WRAPPER_ALL_PART(NAME, TYPE) \ DEFINE_QLIST_WRAPPER_ ## PTR_VALUE ## _PART(NAME, TYPE) \ /** @internal * size, free and make_list. */ #define DEFINE_QLIST_WRAPPER_ALL_PART(NAME, TYPE) \ CL_SMOKE_QT_EXPORT void \ cl_smoke_free_list_ ## NAME (void* list) \ { \ delete static_cast*>(list); \ } \ \ CL_SMOKE_QT_EXPORT void* \ cl_smoke_make_list_ ## NAME () \ { \ return new QList< TYPE >(); \ } \ \ /** @internal * At and append for pointer types */ #define DEFINE_QLIST_WRAPPER_PTR_PART(NAME, TYPE) \ CL_SMOKE_QT_EXPORT const void* \ cl_smoke_list_ ## NAME ## _at(const void* list, int index) \ { \ const QList< TYPE >* qlist = static_cast *>(list); \ return qlist->at(index); \ } \ \ CL_SMOKE_QT_EXPORT void \ cl_smoke_list_ ## NAME ## _append(void* list, void* data) \ { \ static_cast*>(list) \ ->append(static_cast(data)); \ } \ /** @internal * At and append for value types. */ #define DEFINE_QLIST_WRAPPER_VALUE_PART(NAME, TYPE) \ CL_SMOKE_QT_EXPORT const void* \ cl_smoke_list_ ## NAME ## _at(const void* list, int index) \ { \ const QList< TYPE >* qlist = static_cast *>(list); \ return new TYPE(qlist->at(index)); \ } \ \ CL_SMOKE_QT_EXPORT void \ cl_smoke_list_ ## NAME ## _append(void* list, void* data) \ { \ static_cast*>(list) \ ->append(*static_cast(data)); \ } \ #endif // CL_SMOKE_QT_QLIST_H