本文整理汇总了C++中qToBigEndian函数的典型用法代码示例。如果您正苦于以下问题:C++ qToBigEndian函数的具体用法?C++ qToBigEndian怎么用?C++ qToBigEndian使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qToBigEndian函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LOG
/**
* SendResendRequest:
* Request RAOP client to resend missed RTP packets
*/
void MythRAOPConnection::SendResendRequest(uint64_t timestamp,
uint16_t expected, uint16_t got)
{
if (!m_clientControlSocket)
return;
int16_t missed = (got < expected) ?
(int16_t)(((int32_t)got + UINT16_MAX + 1) - expected) :
got - expected;
LOG(VB_GENERAL, LOG_INFO, LOC +
QString("Missed %1 packet(s): expected %2 got %3 ts:%4")
.arg(missed).arg(expected).arg(got).arg(timestamp));
char req[8];
req[0] = 0x80;
req[1] = RANGE_RESEND | 0x80;
*(uint16_t *)(req + 2) = qToBigEndian(m_seqNum++);
*(uint16_t *)(req + 4) = qToBigEndian(expected); // missed seqnum
*(uint16_t *)(req + 6) = qToBigEndian(missed); // count
if (m_clientControlSocket->writeDatagram(req, sizeof(req),
m_peerAddress, m_clientControlPort)
== sizeof(req))
{
for (uint16_t count = 0; count < missed; count++)
{
LOG(VB_GENERAL, LOG_INFO, LOC + QString("Sent resend for %1")
.arg(expected + count));
m_resends.insert(expected + count, timestamp);
}
}
else
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to send resend request.");
}
开发者ID:stunami,项目名称:mythtv,代码行数:39,代码来源:mythraopconnection.cpp
示例2: writeHeader
void RpcConnection::writeHeader(char* header, quint16 type, quint16 method,
quint32 length)
{
*((quint16*)(header+0)) = qToBigEndian(type);
*((quint16*)(header+2)) = qToBigEndian(method);
*((quint32*)(header+4)) = qToBigEndian(length);
}
开发者ID:anju61188,项目名称:ostinato,代码行数:7,代码来源:rpcconn.cpp
示例3: gettimeofday
/**
* SendTimeRequest:
* Send a time request to the RAOP client.
*/
void MythRAOPConnection::SendTimeRequest(void)
{
if (!m_clientControlSocket) // should never happen
return;
timeval t;
gettimeofday(&t, NULL);
char req[32];
req[0] = 0x80;
req[1] = TIMING_REQUEST | 0x80;
// this is always 0x00 0x07 according to http://blog.technologeek.org/airtunes-v2
// no other value works
req[2] = 0x00;
req[3] = 0x07;
*(uint32_t *)(req + 4) = (uint32_t)0;
*(uint64_t *)(req + 8) = (uint64_t)0;
*(uint64_t *)(req + 16) = (uint64_t)0;
*(uint32_t *)(req + 24) = qToBigEndian((uint32_t)t.tv_sec);
*(uint32_t *)(req + 28) = qToBigEndian((uint32_t)t.tv_usec);
if (m_clientTimingSocket->writeDatagram(req, sizeof(req), m_peerAddress, m_clientTimingPort) != sizeof(req))
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to send resend time request.");
return;
}
LOG(VB_GENERAL, LOG_DEBUG, LOC +
QString("Requesting master time (Local %1.%2)")
.arg(t.tv_sec).arg(t.tv_usec));
}
开发者ID:stunami,项目名称:mythtv,代码行数:34,代码来源:mythraopconnection.cpp
示例4: qWarning
QByteArray SettingsFrame::dump(StreamContext& context) const
{
if (context.identifier != 0) {
qWarning() << "SETTINGS Frame identifier must be 0";
}
QByteArray payload;
if (!ack_) {
payload.resize(settings_.size() * 8);
uchar* payloadPtr = reinterpret_cast<uchar*>(payload.data());
for(SettingsType key: settings_.keys()) {
quint32 value = settings_[key];
qToBigEndian(static_cast<quint32>(key), payloadPtr);
payloadPtr += sizeof(quint32);
qToBigEndian(value, payloadPtr);
payloadPtr += sizeof(quint32);
}
}
uchar flags = 0;
if (ack_) flags |= SETTINGS_FLAG_ACK;
BasicFrame frame;
frame.setType(FRAME_SETTINGS);
frame.setFlags(flags);
frame.setPayload(payload);
frame.setIdentifier(0);
return frame.dump();
}
开发者ID:h2so5,项目名称:http2-qt,代码行数:31,代码来源:settingsframe.cpp
示例5: pos
void CryptFileDevice::initCtr(CtrState *state, const unsigned char *iv)
{
qint64 position = pos();
state->num = position % AES_BLOCK_SIZE;
memset(state->ecount, 0, 16);
/* Initialise counter in 'ivec' */
qint64 count = position / AES_BLOCK_SIZE;
if (state->num > 0)
count++;
qint64 newCount = count;
if (newCount > 0)
newCount = qToBigEndian(count);
memcpy(state->ivec + 8, &newCount, 8);
/* Copy IV into 'ivec' */
memcpy(state->ivec, iv, 8);
if (count > 0)
{
count = qToBigEndian(count - 1);
unsigned char * prevIvec = new unsigned char[16];
memcpy(prevIvec, state->ivec, 8);
memcpy(prevIvec + 8, &count, 8);
AES_encrypt(prevIvec, state->ecount, &m_aesKey);
}
}
开发者ID:Vardan07,项目名称:CryptFileDevice,代码行数:33,代码来源:cryptfiledevice.cpp
示例6: qToBigEndian
int MovePointer::serializePayload(uchar *data) const
{
uchar *ptr = data;
qToBigEndian(m_x, ptr); ptr += 4;
qToBigEndian(m_y, ptr); ptr += 4;
return ptr-data;
}
开发者ID:tokyogeometry,项目名称:Drawpile,代码行数:8,代码来源:meta2.cpp
示例7: foreach
int PenMove::serializePayload(uchar *data) const
{
uchar *ptr = data;
*(ptr++) = contextId();
foreach(const PenPoint &p, _points) {
qToBigEndian(p.x, ptr); ptr += 4;
qToBigEndian(p.y, ptr); ptr += 4;
qToBigEndian(p.p, ptr); ptr += 2;
}
开发者ID:EvilKitty3,项目名称:Drawpile,代码行数:9,代码来源:pen.cpp
示例8: foreach
int PenMove::serializePayload(uchar *data) const
{
uchar *ptr = data;
*(ptr++) = _ctx;
foreach(const PenPoint &p, _points) {
qToBigEndian(p.x, ptr); ptr += 2;
qToBigEndian(p.y, ptr); ptr += 2;
*(ptr++) = p.p;
}
开发者ID:hexaditidom,项目名称:Drawpile,代码行数:9,代码来源:pen.cpp
示例9: QColor
void LedGridControllerUT::setPixel()
{
MyMock::expectOneCallAndReturnInt(QString("open_fbdev"), 1);
LedGridController *controller = LedGridController::getInstance();
controller->setPixel(0,0, QColor(0x80,0x0,0xFF));
QCOMPARE(controller->frameBuffer[0], qToBigEndian((quint16)0x781F));
controller->setPixel(3,4, QColor(0xFF,0xFF,0xFF));
QCOMPARE(controller->frameBuffer[(4*8)+3], qToBigEndian((quint16)0xFFFF));
}
开发者ID:fantas0s,项目名称:qt-sense-hat,代码行数:9,代码来源:ledgridcontrollerut.cpp
示例10: qToBigEndian
int CanvasResize::serializePayload(uchar *data) const
{
uchar *ptr = data;
*(ptr++) = contextId();
qToBigEndian(_top, ptr); ptr += 2;
qToBigEndian(_right, ptr); ptr += 2;
qToBigEndian(_bottom, ptr); ptr += 2;
qToBigEndian(_left, ptr); ptr += 2;
return ptr - data;
}
开发者ID:Acru,项目名称:Drawpile,代码行数:10,代码来源:layer.cpp
示例11: qToBigEndian
int MovePointer::serializePayload(uchar *data) const
{
uchar *ptr = data;
*(ptr++) = contextId();
qToBigEndian(_x, ptr); ptr += 4;
qToBigEndian(_y, ptr); ptr += 4;
*(ptr++) = _persistence;
return ptr-data;
}
开发者ID:GreenReaper,项目名称:Drawpile,代码行数:10,代码来源:meta.cpp
示例12: qToBigEndian
int PenMove::serializePayload(uchar *data) const
{
uchar *ptr = data;
for(const PenPoint &p : _points) {
qToBigEndian(p.x, ptr); ptr += 4;
qToBigEndian(p.y, ptr); ptr += 4;
qToBigEndian(p.p, ptr); ptr += 2;
}
return ptr - data;
}
开发者ID:Rambo2015,项目名称:Drawpile,代码行数:10,代码来源:pen.cpp
示例13: qToBigEndian
int AnnotationReshape::serializePayload(uchar *data) const
{
uchar *ptr = data;
*(ptr++) = contextId();
*(ptr++) = _id;
qToBigEndian(_x, ptr); ptr += 4;
qToBigEndian(_y, ptr); ptr += 4;
qToBigEndian(_w, ptr); ptr += 2;
qToBigEndian(_h, ptr); ptr += 2;
return ptr - data;
}
开发者ID:GreenReaper,项目名称:Drawpile,代码行数:11,代码来源:annotation.cpp
示例14: qToBigEndian
void ClientSocket::sendDeleteKeyCommand(const QString &trackName, int row)
{
if (!connected() ||
clientTracks.count(trackName) == 0)
return;
quint32 track = qToBigEndian((quint32)clientTracks[trackName]);
row = qToBigEndian((quint32)row);
unsigned char cmd = DELETE_KEY;
send((char *)&cmd, 1, false);
send((char *)&track, sizeof(int), false);
send((char *)&row, sizeof(int), true);
}
开发者ID:yonglehou,项目名称:rocket-1,代码行数:14,代码来源:clientsocket.cpp
示例15: qLog
TinySVCMDNS::TinySVCMDNS() {
// Get all network interfaces
QList<QNetworkInterface> network_interfaces =
QNetworkInterface::allInterfaces();
for (QNetworkInterface network_interface : network_interfaces) {
// Only use up and non loopback interfaces
if (network_interface.flags().testFlag(network_interface.IsUp) &&
!network_interface.flags().testFlag(network_interface.IsLoopBack)) {
uint32_t ipv4 = 0;
QString ipv6;
qLog(Debug) << "Interface" << network_interface.humanReadableName();
// Now check all network addresses for this device
QList<QNetworkAddressEntry> network_address_entries =
network_interface.addressEntries();
for (QNetworkAddressEntry network_address_entry :
network_address_entries) {
QHostAddress host_address = network_address_entry.ip();
if (host_address.protocol() == QAbstractSocket::IPv4Protocol) {
ipv4 = qToBigEndian(host_address.toIPv4Address());
qLog(Debug) << " ipv4:" << host_address.toString();
} else if (host_address.protocol() == QAbstractSocket::IPv6Protocol) {
ipv6 = host_address.toString();
qLog(Debug) << " ipv6:" << host_address.toString();
}
}
// Now start the service
CreateMdnsd(ipv4, ipv6);
}
}
}
开发者ID:Aceler,项目名称:Clementine,代码行数:34,代码来源:tinysvcmdns.cpp
示例16: DNSServiceRegister
/*
* DnsServiceRegistrar::add
*
* Registers a new service.
*
* Parameters:
* - type: service type
* - port: port number of the registered service
* - name: service name (optional)
*
* Return value: reference of the DNS service if registration was successful, NULL otherwise
*/
DNSServiceRef DnsServiceRegistrar::add(const QString& type, quint16 port, const QString& name)
{
/* Deal with name default value */
char *nameStr;
if (name == "") {
nameStr = NULL;
} else {
nameStr = name.toUtf8().data();
}
/* Create and register the new service ref. */
DNSServiceRef ref;
DNSServiceErrorType err = DNSServiceRegister(&ref, 0, 0, nameStr, type.toUtf8().data(), NULL,
NULL, qToBigEndian(port), 0, NULL, registerCallback, this);
if (err != kDNSServiceErr_NoError) {
Model::logger().addEntry(Logger::Error, QString("Error while registering service (error code = %1)").arg(err));
return NULL;
}
/* Create the QSocketNotifier */
int sockFd = DNSServiceRefSockFD(ref);
RefNotifier *pNotif = new RefNotifier(ref, sockFd, QSocketNotifier::Read, this);
connect(pNotif, SIGNAL(activated(int)), this, SLOT(onNotifierActivated()));
return ref;
}
开发者ID:picardb,项目名称:QtRemote,代码行数:38,代码来源:DnsServiceRegistrar.cpp
示例17: Q_D
bool LwIPTcpServer::listen(const QHostAddress &address, quint16 port) {
Q_D(LwIPTcpServer);
if(d->conn == 0) {
d->conn = LwIPDispatcher::createConn(NETCONN_TCP, this);
if(d->conn == 0) {
return false;
}
struct ip_addr addr;
addr.addr = qToBigEndian(address.toIPv4Address());
if(netconn_bind(d->conn, &addr, port) != ERR_OK)
goto failure;
if(netconn_listen(d->conn) != ERR_OK)
goto failure;
d->serverAddress = address;
d->serverPort = port;
return true;
} else
return false;
failure:
LwIPDispatcher::disposeConn(d->conn);
d->conn = 0;
return false;
}
开发者ID:whitequark,项目名称:sparkle,代码行数:34,代码来源:LwIPTcpServer.cpp
示例18: deriveKeyPbkdf2
static QByteArray deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm,
const QByteArray &data, const QByteArray &salt,
int iterations, quint64 dkLen)
{
QByteArray key;
quint32 currentIteration = 1;
QMessageAuthenticationCode hmac(algorithm, data);
QByteArray index(4, Qt::Uninitialized);
while (quint64(key.length()) < dkLen) {
hmac.addData(salt);
qToBigEndian(currentIteration, reinterpret_cast<uchar*>(index.data()));
hmac.addData(index);
QByteArray u = hmac.result();
hmac.reset();
QByteArray tkey = u;
for (int iter = 1; iter < iterations; iter++) {
hmac.addData(u);
u = hmac.result();
hmac.reset();
std::transform(tkey.cbegin(), tkey.cend(), u.cbegin(), tkey.begin(),
std::bit_xor<char>());
}
key += tkey;
currentIteration++;
}
return key.left(dkLen);
}
开发者ID:qxmpp-project,项目名称:qxmpp,代码行数:27,代码来源:QXmppSasl.cpp
示例19: qrand
void Core::bootstrapDht()
{
const Settings& s = Settings::getInstance();
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
int listSize = dhtServerList.size();
static int j = qrand() % listSize, n=0;
// We couldn't connect after trying 6 different nodes, let's try something else
if (n>3)
{
qDebug() << "Core: We're having trouble connecting to the DHT, slowing down";
bootstrapTimer->setInterval(TOX_BOOTSTRAP_INTERVAL*(n-1));
}
else
qDebug() << "Core: Connecting to the DHT ...";
int i=0;
while (i < (2 - (n>3)))
{
const Settings::DhtServer& dhtServer = dhtServerList[j % listSize];
if (tox_bootstrap_from_address(tox, dhtServer.address.toLatin1().data(),
qToBigEndian(dhtServer.port), CUserId(dhtServer.userId).data()) == 1)
qDebug() << QString("Core: Bootstraping from ")+dhtServer.name+QString(", addr ")+dhtServer.address.toLatin1().data()
+QString(", port ")+QString().setNum(dhtServer.port);
else
qDebug() << "Core: Error bootstraping from "+dhtServer.name;
tox_do(tox);
j++;
i++;
n++;
}
}
开发者ID:ReDetection,项目名称:qTox,代码行数:34,代码来源:core.cpp
示例20: castWithEndian
static inline T castWithEndian(T src)
{
if(Socket_Handler::endian() == QSysInfo::BigEndian)
return qToBigEndian(src);
else
return qToLittleEndian(src);
}
开发者ID:Gremory,项目名称:hpcourse,代码行数:7,代码来源:socket_handler.cpp
注:本文中的qToBigEndian函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论