#include "cl_smoke_qt.h" #include #include /** @file * @brief QStringList conversion. */ extern "C" { /** Returns the number of items of @a string_list. * @param string_list the QStringList * * @return the number of items */ CL_SMOKE_QT_EXPORT int cl_smoke_string_list_size(const void* string_list) { Q_ASSERT(string_list); return static_cast(string_list)->size(); } /** Returns the byte array of @a string_list at position @a index. * @param string_list the QStringList * @param index the index of the string * * @return a new allocated byte-array */ CL_SMOKE_QT_EXPORT void* cl_smoke_string_list_at(const void* string_list, int index) { Q_ASSERT(string_list); const QStringList* list = static_cast(string_list); Q_ASSERT(0 <= index && index < list->size()); return new QByteArray(list->at(index).toLocal8Bit()); } /** Free a QStringList. * @param string_list the QStringList to free */ CL_SMOKE_QT_EXPORT void cl_smoke_free_string_list(void* string_list) { delete static_cast(string_list); } /** Allocates a new QStringList. * * @return a new QStringList */ CL_SMOKE_QT_EXPORT void* cl_smoke_make_string_list() { return new QStringList(); } /** Appends @a string to @a string_list * @param string_list the QStringList * @param data the string * @param length the length of @a data */ CL_SMOKE_QT_EXPORT void cl_smoke_string_list_append(void* string_list, const char* data, int length) { static_cast(string_list)->append(QString::fromLocal8Bit(data, length)); } } // extern "C"