本文整理汇总了C++中Sender::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ Sender::isEmpty方法的具体用法?C++ Sender::isEmpty怎么用?C++ Sender::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sender
的用法示例。
在下文中一共展示了Sender::isEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toMessage
SettingsMessage SettingsMessage::toMessage(const QVariant & message,
const Sender & sender,
const Reciever & reciever,
const Recievers & recievers,
const ReliableTime & reliableTime) {
QVariantMap messageMap = message.toMap();
QVariantMap msHeader = messageMap["header"].toMap();
Recievers recieversList;
for (const QVariant & reciever : msHeader["recievers"].toList()) {
recieversList << reciever.value<Reciever>();
}
Message::SettingsMessage ms(
sender.isEmpty() ? msHeader["sender"].value<Message::Sender>() : sender,
reciever.isEmpty() ? msHeader["reciever"].value<Message::Reciever>() : reciever,
recievers.isEmpty() ? recieversList : recievers
);
if (msHeader.contains("reliableTime")) {
ms.setReliableTime(reliableTime == ReliableTime(-1) ? msHeader["reliableTime"].value<Message::ReliableTime>() : reliableTime);
}
ms.data = messageMap["data"].toMap();
return ms;
}
示例2: toVariantMap
QVariantMap SettingsMessage::toVariantMap(const SettingsMessage & message,
const Sender & sender,
const Reciever & reciever,
const Recievers & recievers,
const ReliableTime & reliableTime) {
QVariantMap map;
map["header"] = QVariantMap() = {
{ "sender", sender.isEmpty() ? message.sender() : sender },
{ "reciever", reciever.isEmpty() ? message.reciever() : reciever },
{ "recievers", recievers.isEmpty() ? QVariant(message.recievers()) : QVariant(recievers) },
{ "reliableTime", reliableTime == ReliableTime(-1) ? message.reliableTime() : reliableTime }
};
QVariantMap mapData;
QVariantMap mapKeyVarMS;
QVariantMap mapKeyMS;
for (const QString & key : message.data.keys()) {
if (key != "action") {
mapKeyMS = message.data[key].toMap();
for (const QString & keykey : mapKeyMS.keys()) {
mapKeyVarMS[keykey] = mapKeyMS[keykey];
}
mapData[key] = mapKeyVarMS;
mapKeyVarMS.clear();
}
}
mapData["action"] = message.data["action"];
map["data"] = mapData;
return map;
}