miqt/qt6/network/gen_qudpsocket.cpp
2024-11-06 18:39:26 +13:00

152 lines
5.1 KiB
C++

#include <QByteArray>
#include <QHostAddress>
#include <QMetaObject>
#include <QNetworkDatagram>
#include <QNetworkInterface>
#include <QObject>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <QUdpSocket>
#include <qudpsocket.h>
#include "gen_qudpsocket.h"
#include "_cgo_export.h"
QUdpSocket* QUdpSocket_new() {
return new QUdpSocket();
}
QUdpSocket* QUdpSocket_new2(QObject* parent) {
return new QUdpSocket(parent);
}
QMetaObject* QUdpSocket_MetaObject(const QUdpSocket* self) {
return (QMetaObject*) self->metaObject();
}
void* QUdpSocket_Metacast(QUdpSocket* self, const char* param1) {
return self->qt_metacast(param1);
}
struct miqt_string QUdpSocket_Tr(const char* s) {
QString _ret = QUdpSocket::tr(s);
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
bool QUdpSocket_Bind(QUdpSocket* self, int addr) {
return self->bind(static_cast<QHostAddress::SpecialAddress>(addr));
}
bool QUdpSocket_JoinMulticastGroup(QUdpSocket* self, QHostAddress* groupAddress) {
return self->joinMulticastGroup(*groupAddress);
}
bool QUdpSocket_JoinMulticastGroup2(QUdpSocket* self, QHostAddress* groupAddress, QNetworkInterface* iface) {
return self->joinMulticastGroup(*groupAddress, *iface);
}
bool QUdpSocket_LeaveMulticastGroup(QUdpSocket* self, QHostAddress* groupAddress) {
return self->leaveMulticastGroup(*groupAddress);
}
bool QUdpSocket_LeaveMulticastGroup2(QUdpSocket* self, QHostAddress* groupAddress, QNetworkInterface* iface) {
return self->leaveMulticastGroup(*groupAddress, *iface);
}
QNetworkInterface* QUdpSocket_MulticastInterface(const QUdpSocket* self) {
return new QNetworkInterface(self->multicastInterface());
}
void QUdpSocket_SetMulticastInterface(QUdpSocket* self, QNetworkInterface* iface) {
self->setMulticastInterface(*iface);
}
bool QUdpSocket_HasPendingDatagrams(const QUdpSocket* self) {
return self->hasPendingDatagrams();
}
long long QUdpSocket_PendingDatagramSize(const QUdpSocket* self) {
qint64 _ret = self->pendingDatagramSize();
return static_cast<long long>(_ret);
}
QNetworkDatagram* QUdpSocket_ReceiveDatagram(QUdpSocket* self) {
return new QNetworkDatagram(self->receiveDatagram());
}
long long QUdpSocket_ReadDatagram(QUdpSocket* self, char* data, long long maxlen) {
qint64 _ret = self->readDatagram(data, static_cast<qint64>(maxlen));
return static_cast<long long>(_ret);
}
long long QUdpSocket_WriteDatagram(QUdpSocket* self, QNetworkDatagram* datagram) {
qint64 _ret = self->writeDatagram(*datagram);
return static_cast<long long>(_ret);
}
long long QUdpSocket_WriteDatagram2(QUdpSocket* self, const char* data, long long lenVal, QHostAddress* host, uint16_t port) {
qint64 _ret = self->writeDatagram(data, static_cast<qint64>(lenVal), *host, static_cast<quint16>(port));
return static_cast<long long>(_ret);
}
long long QUdpSocket_WriteDatagram3(QUdpSocket* self, struct miqt_string datagram, QHostAddress* host, uint16_t port) {
QByteArray datagram_QByteArray(datagram.data, datagram.len);
qint64 _ret = self->writeDatagram(datagram_QByteArray, *host, static_cast<quint16>(port));
return static_cast<long long>(_ret);
}
struct miqt_string QUdpSocket_Tr2(const char* s, const char* c) {
QString _ret = QUdpSocket::tr(s, c);
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
struct miqt_string QUdpSocket_Tr3(const char* s, const char* c, int n) {
QString _ret = QUdpSocket::tr(s, c, static_cast<int>(n));
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
bool QUdpSocket_Bind2(QUdpSocket* self, int addr, uint16_t port) {
return self->bind(static_cast<QHostAddress::SpecialAddress>(addr), static_cast<quint16>(port));
}
bool QUdpSocket_Bind3(QUdpSocket* self, int addr, uint16_t port, int mode) {
return self->bind(static_cast<QHostAddress::SpecialAddress>(addr), static_cast<quint16>(port), static_cast<QAbstractSocket::BindMode>(mode));
}
QNetworkDatagram* QUdpSocket_ReceiveDatagram1(QUdpSocket* self, long long maxSize) {
return new QNetworkDatagram(self->receiveDatagram(static_cast<qint64>(maxSize)));
}
long long QUdpSocket_ReadDatagram3(QUdpSocket* self, char* data, long long maxlen, QHostAddress* host) {
qint64 _ret = self->readDatagram(data, static_cast<qint64>(maxlen), host);
return static_cast<long long>(_ret);
}
long long QUdpSocket_ReadDatagram4(QUdpSocket* self, char* data, long long maxlen, QHostAddress* host, uint16_t* port) {
qint64 _ret = self->readDatagram(data, static_cast<qint64>(maxlen), host, static_cast<quint16*>(port));
return static_cast<long long>(_ret);
}
void QUdpSocket_Delete(QUdpSocket* self) {
delete self;
}