97 lines
2.9 KiB
C++
97 lines
2.9 KiB
C++
/* generated by rust_qt_binding_generator */
|
|
#include "test_functions_rust.h"
|
|
|
|
namespace {
|
|
|
|
typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
|
|
void set_qstring(QString* val, const char* utf8, int nbytes) {
|
|
*val = QString::fromUtf8(utf8, nbytes);
|
|
}
|
|
|
|
typedef void (*qbytearray_set)(QByteArray* val, const char* bytes, int nbytes);
|
|
void set_qbytearray(QByteArray* v, const char* bytes, int nbytes) {
|
|
if (v->isNull() && nbytes == 0) {
|
|
*v = QByteArray(bytes, nbytes);
|
|
} else {
|
|
v->truncate(0);
|
|
v->append(bytes, nbytes);
|
|
}
|
|
}
|
|
inline void personUserNameChanged(Person* o)
|
|
{
|
|
Q_EMIT o->userNameChanged();
|
|
}
|
|
}
|
|
extern "C" {
|
|
Person::Private* person_new(Person*, void (*)(Person*));
|
|
void person_free(Person::Private*);
|
|
void person_user_name_get(const Person::Private*, QString*, qstring_set);
|
|
void person_user_name_set(Person::Private*, const ushort *str, int len);
|
|
void person_append(Person::Private*, const ushort*, int, quint32);
|
|
void person_double_name(Person::Private*);
|
|
void person_greet(const Person::Private*, const ushort*, int, QString*, qstring_set);
|
|
void person_quote(const Person::Private*, const ushort*, int, const ushort*, int, QString*, qstring_set);
|
|
void person_quote_bytes(const Person::Private*, const char*, int, const char*, int, QByteArray*, qbytearray_set);
|
|
quint8 person_vowels_in_name(const Person::Private*);
|
|
};
|
|
|
|
Person::Person(bool /*owned*/, QObject *parent):
|
|
QObject(parent),
|
|
m_d(nullptr),
|
|
m_ownsPrivate(false)
|
|
{
|
|
}
|
|
|
|
Person::Person(QObject *parent):
|
|
QObject(parent),
|
|
m_d(person_new(this,
|
|
personUserNameChanged)),
|
|
m_ownsPrivate(true)
|
|
{
|
|
}
|
|
|
|
Person::~Person() {
|
|
if (m_ownsPrivate) {
|
|
person_free(m_d);
|
|
}
|
|
}
|
|
QString Person::userName() const
|
|
{
|
|
QString v;
|
|
person_user_name_get(m_d, &v, set_qstring);
|
|
return v;
|
|
}
|
|
void Person::setUserName(const QString& v) {
|
|
person_user_name_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
|
|
}
|
|
void Person::append(const QString& suffix, quint32 amount)
|
|
{
|
|
return person_append(m_d, suffix.utf16(), suffix.size(), amount);
|
|
}
|
|
void Person::doubleName()
|
|
{
|
|
return person_double_name(m_d);
|
|
}
|
|
QString Person::greet(const QString& name) const
|
|
{
|
|
QString s;
|
|
person_greet(m_d, name.utf16(), name.size(), &s, set_qstring);
|
|
return s;
|
|
}
|
|
QString Person::quote(const QString& prefix, const QString& suffix) const
|
|
{
|
|
QString s;
|
|
person_quote(m_d, prefix.utf16(), prefix.size(), suffix.utf16(), suffix.size(), &s, set_qstring);
|
|
return s;
|
|
}
|
|
QByteArray Person::quoteBytes(const QByteArray& prefix, const QByteArray& suffix) const
|
|
{
|
|
QByteArray s;
|
|
person_quote_bytes(m_d, prefix.data(), prefix.size(), suffix.data(), suffix.size(), &s, set_qbytearray);
|
|
return s;
|
|
}
|
|
quint8 Person::vowelsInName() const
|
|
{
|
|
return person_vowels_in_name(m_d);
|
|
}
|