当前位置: 首页>>代码示例>>C++>>正文


C++ QVector::removeOne方法代码示例

本文整理汇总了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;
}
开发者ID:dtaralla,项目名称:hearthstone,代码行数:13,代码来源:groupexpression.cpp

示例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);
//.........这里部分代码省略.........
开发者ID:psi-plus,项目名称:plugins,代码行数:101,代码来源:omemo.cpp


注:本文中的QVector::removeOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。