本文整理汇总了C++中QVector::removeOne方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::removeOne方法的具体用法?C++ QVector::removeOne怎么用?C++ QVector::removeOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::removeOne方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
QVector<Character*>* GroupExpression::eval(Card* caster, const Event* e) const
{
QVector<Character*>* group = caster->owner()->game()->charactersByPlayTime(caster->owner(), m_owner, m_type);
if (!m_excludedTargets.isNull()) {
QVector<Character*>* excluded = m_excludedTargets.data()->eval(caster, NULL, e);
foreach (Character* c, *excluded)
group->removeOne(c);
delete excluded;
}
return group;
}
示例2: encryptMessage
bool OMEMO::encryptMessage(const QString &ownJid, int account, QDomElement &xml, bool buildSessions, const uint32_t *toDeviceId) {
std::shared_ptr<Signal> signal = getSignal(account);
QString recipient = m_contactInfoAccessor->realJid(account, xml.attribute("to")).split("/").first();
bool isGroup = xml.attribute("type") == "groupchat";
if (!isEnabledForUser(account, recipient)) {
return false;
}
if (buildSessions) {
QMap<QString, QVector<uint32_t>> invalidSessions;
QVector<uint32_t> invalidSessionsWithOwnDevices;
if (isGroup) {
forEachMucParticipant(account, ownJid, recipient, [&](const QString &userJid) {
QVector<uint32_t> sessions = signal->invalidSessions(userJid);
if (!sessions.isEmpty()) {
invalidSessions.insert(userJid, sessions);
}
return true;
});
}
else {
QVector<uint32_t> sessions = signal->invalidSessions(recipient);
if (!sessions.isEmpty()) {
invalidSessions.insert(recipient, sessions);
}
}
invalidSessionsWithOwnDevices = signal->invalidSessions(ownJid);
invalidSessionsWithOwnDevices.removeOne(signal->getDeviceId());
if (!invalidSessions.isEmpty() || !invalidSessionsWithOwnDevices.isEmpty()) {
buildSessionsFromBundle(invalidSessions, invalidSessionsWithOwnDevices, ownJid, account, xml);
xml = QDomElement();
return true;
}
}
signal->processUndecidedDevices(recipient, false);
signal->processUndecidedDevices(ownJid, true);
QDomElement encrypted = xml.ownerDocument().createElementNS(OMEMO_XMLNS, "encrypted");
QDomElement header = xml.ownerDocument().createElement("header");
header.setAttribute("sid", signal->getDeviceId());
encrypted.appendChild(header);
xml.appendChild(encrypted);
QByteArray iv = Crypto::randomBytes(OMEMO_AES_GCM_IV_LENGTH);
QDomElement ivElement = xml.ownerDocument().createElement("iv");
ivElement.appendChild(xml.ownerDocument().createTextNode(iv.toBase64()));
header.appendChild(ivElement);
QByteArray key = Crypto::randomBytes(OMEMO_AES_128_KEY_LENGTH);
QDomElement body = xml.firstChildElement("body");
QPair<QByteArray, QByteArray> encryptedBody;
if (!body.isNull()) {
QString plainText = body.firstChild().nodeValue();
encryptedBody = Crypto::aes_gcm(Crypto::Encode, iv, key, plainText.toUtf8());
key += encryptedBody.second;
}
QList<EncryptedKey> encryptedKeys;
if (isGroup) {
forEachMucParticipant(account, ownJid, recipient, [&](const QString &userJid) {
encryptedKeys.append(signal->encryptKey(ownJid, userJid, key));
return true;
});
}
else {
encryptedKeys = signal->encryptKey(ownJid, recipient, key);
}
if (encryptedKeys.isEmpty()) {
m_accountController->appendSysMsg(account, xml.attribute("to"), "[OMEMO] Unable to build any sessions, the message was not sent");
xml = QDomElement();
}
else {
foreach (EncryptedKey encKey, encryptedKeys) {
if (toDeviceId != nullptr && *toDeviceId != encKey.deviceId) {
continue;
}
QDomElement keyElement = xml.ownerDocument().createElement("key");
keyElement.setAttribute("rid", encKey.deviceId);
if (encKey.isPreKey) {
keyElement.setAttribute("prekey", 1);
}
setNodeText(keyElement, encKey.key);
header.appendChild(keyElement);
}
if (!body.isNull()) {
if (isGroup) {
m_encryptedGroupMessages.insert(xml.attribute("id"), body.firstChild().nodeValue());
}
xml.removeChild(body);
QDomElement payload = xml.ownerDocument().createElement("payload");
payload.appendChild(xml.ownerDocument().createTextNode(encryptedBody.first.toBase64()));
encrypted.appendChild(payload);
QDomElement html = xml.firstChildElement("html");
if (!html.isNull()) {
xml.removeChild(html);
//.........这里部分代码省略.........