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


C++ Name::wireEncode方法代码示例

本文整理汇总了C++中Name::wireEncode方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::wireEncode方法的具体用法?C++ Name::wireEncode怎么用?C++ Name::wireEncode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Name的用法示例。


在下文中一共展示了Name::wireEncode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

shared_ptr<Data>
ActionLog::LookupActionData(const Name& deviceName, sqlite3_int64 seqno)
{
  sqlite3_stmt* stmt;
  sqlite3_prepare_v2(m_db,
                     "SELECT action_content_object FROM ActionLog WHERE device_name=? AND seq_no=?",
                     -1, &stmt, 0);

  sqlite3_bind_blob(stmt, 1, deviceName.wireEncode().wire(), deviceName.wireEncode().size(),
                    SQLITE_STATIC); // ndn version
  sqlite3_bind_int64(stmt, 2, seqno);

  shared_ptr<Data> retval;

  if (sqlite3_step(stmt) == SQLITE_ROW) {
    // _LOG_DEBUG(sqlite3_column_blob(stmt, 0) << ", " << sqlite3_column_bytes(stmt, 0));
    retval = make_shared<Data>();
    retval->wireDecode(Block(reinterpret_cast<const uint8_t*>(sqlite3_column_blob(stmt, 0)),
                             sqlite3_column_bytes(stmt, 0)));
  }
  else {
    _LOG_TRACE("No action found for deviceName [" << deviceName << "] and seqno:" << seqno);
  }
  // _LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_OK && sqlite3_errcode(m_db) != SQLITE_ROW,
  // sqlite3_errmsg(m_db));
  sqlite3_finalize(stmt);

  return retval;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2:

void
PibDb::setDefaultCertNameOfKey(const Name& certificateName)
{
  sqlite3_stmt* statement;
  sqlite3_prepare_v2(m_database,
                     "UPDATE certificates SET is_default=1 WHERE certificate_name=?",
                     -1, &statement, nullptr);
  sqlite3_bind_block(statement, 1, certificateName.wireEncode(), SQLITE_TRANSIENT);
  sqlite3_step(statement);
  sqlite3_finalize(statement);
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:11,代码来源:pib-db.cpp

示例3: identities

int64_t
PibDb::addIdentity(const Name& identity)
{
  sqlite3_stmt* statement;
  sqlite3_prepare_v2(m_database,
                     "INSERT INTO identities (identity) values (?)",
                     -1, &statement, nullptr);
  sqlite3_bind_block(statement, 1, identity.wireEncode(), SQLITE_TRANSIENT);
  sqlite3_step(statement);
  sqlite3_finalize(statement);

  return sqlite3_last_insert_rowid(m_database);
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:13,代码来源:pib-db.cpp

示例4: onValidationFailed

void
ValidatorInvitation::checkPolicy (const Interest& interest,
                                  int stepCount,
                                  const OnInterestValidated& onValidated,
                                  const OnInterestValidationFailed& onValidationFailed,
                                  vector<shared_ptr<ValidationRequest> >& nextSteps)
{
  const Name& interestName  = interest.getName();

  if (!m_invitationInterestRule.match(interestName))
    return onValidationFailed(interest.shared_from_this(),
                              "Invalid interest name: " +  interest.getName().toUri());

  Name signedName = interestName.getPrefix(-1);
  ndn::Buffer signedBlob = ndn::Buffer(signedName.wireEncode().value(),
                                       signedName.wireEncode().value_size());

  Block signatureBlock = interestName.get(Invitation::SIGNATURE).blockFromValue();
  Block signatureInfo = interestName.get(Invitation::KEY_LOCATOR).blockFromValue();
  Signature signature(signatureInfo, signatureBlock);

  if (signature.getKeyLocator().getType() != KeyLocator::KeyLocator_Name)
    return onValidationFailed(interest.shared_from_this(),
                              "KeyLocator is not a name: " + interest.getName().toUri());

  const Name & keyLocatorName = signature.getKeyLocator().getName();

  Data innerData;
  innerData.wireDecode(interestName.get(Invitation::INVITER_CERT).blockFromValue());

  return internalCheck(signedBlob.buf(), signedBlob.size(),
                       signature,
                       keyLocatorName,
                       innerData,
                       bind(onValidated, interest.shared_from_this()),
                       bind(onValidationFailed, interest.shared_from_this(), _1));
}
开发者ID:bruinfish,项目名称:ChronoChat,代码行数:37,代码来源:validator-invitation.cpp

示例5: decryptionkeys

void
Sqlite3ConsumerDb::addKey(const Name& keyName, const Blob& keyBlob)
{
  sqlite3_stmt *statement;
  sqlite3_prepare_v2
    (database_, "INSERT INTO decryptionkeys(key_name, key_buf) values (?, ?)",
     -1, &statement, 0);
  sqlite3_bind_blob(statement, 1, keyName.wireEncode(), SQLITE_TRANSIENT);
  sqlite3_bind_blob(statement, 2, keyBlob, SQLITE_TRANSIENT);

  int status = sqlite3_step(statement);
  sqlite3_finalize(statement);
  if (status != SQLITE_DONE)
    throw ConsumerDb::Error
      ("Sqlite3ConsumerDb::addKey: Cannot add the key to the database");
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例6:

// Interface of different hash functions
size_t
computeHash(const Name& prefix)
{
  prefix.wireEncode();  // guarantees prefix's wire buffer is not empty

  size_t hashValue = 0;
  size_t hashUpdate = 0;

  for (Name::const_iterator it = prefix.begin(); it != prefix.end(); it++)
    {
      const char* wireFormat = reinterpret_cast<const char*>( it->wire() );
      hashUpdate = CityHash::compute(wireFormat, it->size());
      hashValue ^= hashUpdate;
    }

  return hashValue;
}
开发者ID:danposch,项目名称:NFD,代码行数:18,代码来源:name-tree.cpp

示例7: Name

Name
PibDb::getDefaultKeyNameOfIdentity(const Name& identity) const
{
  sqlite3_stmt* statement;
  sqlite3_prepare_v2(m_database,
                     "SELECT key_name FROM keys JOIN identities ON keys.identity_id=identities.id\
                      WHERE identities.identity=? AND keys.is_default=1",
                     -1, &statement, nullptr);
  sqlite3_bind_block(statement, 1, identity.wireEncode(), SQLITE_TRANSIENT);

  Name keyName = NON_EXISTING_KEY;
  if (sqlite3_step(statement) == SQLITE_ROW && sqlite3_column_bytes(statement, 0) != 0) {
    keyName = Name(sqlite3_column_block(statement, 0));
  }

  sqlite3_finalize(statement);
  return keyName;
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:18,代码来源:pib-db.cpp

示例8: keyName

vector<Name>
PibDb::listKeyNamesOfIdentity(const Name& identity) const
{
  vector<Name> keyNames;

  sqlite3_stmt* statement;
  sqlite3_prepare_v2(m_database,
                     "SELECT key_name FROM keys JOIN identities ON keys.identity_id=identities.id\
                      WHERE identities.identity=?",
                     -1, &statement, nullptr);
  sqlite3_bind_block(statement, 1, identity.wireEncode(), SQLITE_TRANSIENT);

  keyNames.clear();
  while (sqlite3_step(statement) == SQLITE_ROW) {
    Name keyName(sqlite3_column_block(statement, 0));
    keyNames.push_back(keyName);
  }

  sqlite3_finalize(statement);
  return keyNames;
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:21,代码来源:pib-db.cpp

示例9: name

vector<Name>
PibDb::listCertNamesOfKey(const Name& keyName) const
{
  vector<Name> certNames;

  sqlite3_stmt* statement;
  sqlite3_prepare_v2(m_database,
                     "SELECT certificate_name\
                      FROM certificates JOIN keys ON certificates.key_id=keys.id\
                      WHERE keys.key_name=?",
                     -1, &statement, nullptr);
  sqlite3_bind_block(statement, 1, keyName.wireEncode(), SQLITE_TRANSIENT);

  certNames.clear();
  while (sqlite3_step(statement) == SQLITE_ROW) {
    Name name(sqlite3_column_block(statement, 0));
    certNames.push_back(name);
  }
  sqlite3_finalize(statement);

  return certNames;
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:22,代码来源:pib-db.cpp

示例10: addIdentity

int64_t
PibDb::addKey(const Name& keyName, const PublicKey& key)
{
  if (keyName.empty())
    return 0;

  Name&& identity = keyName.getPrefix(-1);
  if (!hasIdentity(identity))
    addIdentity(identity);

  sqlite3_stmt* statement;
  sqlite3_prepare_v2(m_database,
                     "INSERT INTO keys (identity_id, key_name, key_type, key_bits) \
                      values ((SELECT id FROM identities WHERE identity=?), ?, ?, ?)",
                     -1, &statement, nullptr);
  sqlite3_bind_block(statement, 1, identity.wireEncode(), SQLITE_TRANSIENT);
  sqlite3_bind_block(statement, 2, keyName.wireEncode(), SQLITE_TRANSIENT);
  sqlite3_bind_int(statement, 3, key.getKeyType());
  sqlite3_bind_blob(statement, 4, key.get().buf(), key.get().size(), SQLITE_STATIC);
  sqlite3_step(statement);
  sqlite3_finalize(statement);

  return sqlite3_last_insert_rowid(m_database);
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:24,代码来源:pib-db.cpp

示例11: ActionItemPtr

ActionItemPtr
ActionLog::AddRemoteAction(const Name& deviceName, sqlite3_int64 seqno, shared_ptr<Data> actionData)
{
  if (!actionData) {
    _LOG_ERROR("actionData is not valid");
    return ActionItemPtr();
  }
  ActionItemPtr action = deserializeMsg<ActionItem>(
    Buffer(actionData->getContent().value(), actionData->getContent().value_size()));

  if (!action) {
    _LOG_ERROR("action cannot be decoded");
    return ActionItemPtr();
  }

  _LOG_DEBUG("AddRemoteAction: [" << deviceName.toUri() << "] seqno: " << seqno);

  sqlite3_stmt* stmt;
  sqlite3_prepare_v2(m_db,
                     "INSERT INTO ActionLog "
                     "(device_name, seq_no, action, filename, version, action_timestamp, "
                     "file_hash, file_atime, file_mtime, file_ctime, file_chmod, file_seg_num, "
                     "parent_device_name, parent_seq_no, "
                     "action_name, action_content_object) "
                     "VALUES (?, ?, ?, ?, ?, datetime(?, 'unixepoch'),"
                     "        ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?,?, "
                     "        ?, ?, "
                     "        ?, ?);",
                     -1, &stmt, 0);
  _LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_OK, sqlite3_errmsg(m_db));

  sqlite3_bind_blob(stmt, 1, deviceName.wireEncode().wire(), deviceName.wireEncode().size(),
                    SQLITE_STATIC);
  sqlite3_bind_int64(stmt, 2, seqno);

  sqlite3_bind_int(stmt, 3, action->action());
  sqlite3_bind_text(stmt, 4, action->filename().c_str(), action->filename().size(), SQLITE_STATIC);
  sqlite3_bind_int64(stmt, 5, action->version());
  sqlite3_bind_int64(stmt, 6, action->timestamp());

  if (action->action() == ActionItem::UPDATE) {
    sqlite3_bind_blob(stmt, 7, action->file_hash().c_str(), action->file_hash().size(),
                      SQLITE_STATIC);

    // sqlite3_bind_int64(stmt, 8, atime); // NULL
    sqlite3_bind_int64(stmt, 9, action->mtime());
    // sqlite3_bind_int64(stmt, 10, ctime); // NULL

    sqlite3_bind_int(stmt, 11, action->mode());
    sqlite3_bind_int(stmt, 12, action->seg_num());
  }

  if (action->has_parent_device_name()) {
    sqlite3_bind_blob(stmt, 13, action->parent_device_name().c_str(),
                      action->parent_device_name().size(), SQLITE_STATIC);
    sqlite3_bind_int64(stmt, 14, action->parent_seq_no());
  }

  Name actionName = Name(deviceName);
  actionName.append("action").append(m_sharedFolderName).appendNumber(seqno);

  sqlite3_bind_blob(stmt, 15, actionName.wireEncode().wire(), actionName.wireEncode().size(),
                    SQLITE_STATIC);
  sqlite3_bind_blob(stmt, 16, actionData->wireEncode().wire(), actionData->wireEncode().size(),
                    SQLITE_STATIC);
  sqlite3_step(stmt);

  // if action needs to be applied to file state, the trigger will take care of it

  _LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_DONE, sqlite3_errmsg(m_db));

  sqlite3_finalize(stmt);

  // I had a problem including directory_name assignment as part of the initial insert.
  sqlite3_prepare_v2(m_db,
                     "UPDATE ActionLog SET directory=directory_name(filename) WHERE device_name=? AND seq_no=?",
                     -1, &stmt, 0);
  _LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_OK, sqlite3_errmsg(m_db));

  sqlite3_bind_blob(stmt, 1, deviceName.wireEncode().wire(), deviceName.wireEncode().size(),
                    SQLITE_STATIC);
  sqlite3_bind_int64(stmt, 2, seqno);
  sqlite3_step(stmt);
  _LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_DONE, sqlite3_errmsg(m_db));

  sqlite3_finalize(stmt);

  return action;
}
开发者ID:,项目名称:,代码行数:89,代码来源:


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