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


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

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


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

示例1:

inline size_t
calculateSkip(const Name& name,
              const Name& hint, const Name& zone)
{
  size_t skip = 0;

  if (!hint.empty()) {
    // These are only asserts. The caller should supply the right parameters
    skip = hint.size() + 1 + zone.size();
    BOOST_ASSERT(name.size() > skip);

    BOOST_ASSERT(name.getPrefix(hint.size()) == hint);
    BOOST_ASSERT(name.get(hint.size()) == FORWARDING_HINT_LABEL);
    BOOST_ASSERT(name.getSubName(hint.size() + 1, zone.size()) == zone);

  }
  else {
    skip = zone.size();
    BOOST_ASSERT(name.size() > skip);
    BOOST_ASSERT(name.getPrefix(zone.size()) == zone);
  }

  BOOST_ASSERT(name.get(skip) == NDNS_ITERATIVE_QUERY ||
               name.get(skip) == NDNS_CERT_QUERY);

  ++skip;
  return skip;
}
开发者ID:cawka,项目名称:ndns,代码行数:28,代码来源:ndns-label.cpp

示例2: idString

bool
IdentityCertificate::isCorrectName(const Name& name)
{
  int i = name.size() - 1;
  
  string idString("ID-CERT");
  for (; i >= 0; i--) {
    if(name.get(i).toEscapedString() == idString)
      break;
  }

  if (i < 0)
    return false;
  
  int keyIdx = 0;
  string keyString("KEY");
  for (; keyIdx < name.size(); keyIdx++) {
    if(name.get(keyIdx).toEscapedString() == keyString)
      break;
  }

  if (keyIdx >= name.size())
    return false;

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

示例3: d

BOOST_FIXTURE_TEST_CASE(FullName, IdentityManagementFixture)
{
  Data d(Name("/local/ndn/prefix"));
  d.setContentType(tlv::ContentType_Blob);
  d.setFreshnessPeriod(10_s);
  d.setContent(CONTENT1, sizeof(CONTENT1));
  BOOST_CHECK_THROW(d.getFullName(), Data::Error); // FullName is unavailable without signing

  m_keyChain.sign(d);
  BOOST_CHECK_EQUAL(d.hasWire(), true);
  Name fullName = d.getFullName(); // FullName is available after signing

  BOOST_CHECK_EQUAL(d.getName().size() + 1, fullName.size());
  BOOST_CHECK_EQUAL_COLLECTIONS(d.getName().begin(), d.getName().end(),
                                fullName.begin(), fullName.end() - 1);
  BOOST_CHECK_EQUAL(fullName.get(-1).value_size(), util::Sha256::DIGEST_SIZE);

  // FullName should be cached, so value() pointer points to same memory location
  BOOST_CHECK_EQUAL(fullName.get(-1).value(), d.getFullName().get(-1).value());

  d.setFreshnessPeriod(100_s); // invalidates FullName
  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  Data d1(Block(DATA1, sizeof(DATA1)));
  BOOST_CHECK_EQUAL(d1.getFullName(),
    "/local/ndn/prefix/"
    "sha256digest=28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548");
}
开发者ID:cawka,项目名称:ndn-cxx,代码行数:28,代码来源:data.t.cpp

示例4: endsWithSegmentNumber

 /**
  * Check if the last component in the name is a segment number.
  * @param name The name to check.
  * @return True if the name ends with a segment number, otherwise false.
  */
 static bool
 endsWithSegmentNumber(Name name)
 {
   return name.size() >= 1 &&
          name.get(-1).getValue().size() >= 1 &&
          name.get(-1).getValue().buf()[0] == 0;
 }
开发者ID:susmit85,项目名称:ndn-cpp,代码行数:12,代码来源:segment-fetcher.hpp

示例5: ActionItemPtr

ActionItemPtr
ActionLog::AddRemoteAction(shared_ptr<Data> actionData)
{
  Name name = actionData->getName();
  // action name: /<device_name>/<appname>/action/<shared-folder>/<action-seq>

  uint64_t seqno = name.get(-1).toNumber();
  std::string sharedFolder = name.get(-2).toUri();

  if (sharedFolder != m_sharedFolderName) {
    _LOG_ERROR("Action doesn't belong to this shared folder");
    return ActionItemPtr();
  }

  if (name.get(-3).toUri() != "action") {
    _LOG_ERROR("not an action");
    return ActionItemPtr();
  }

  if (name.get(-4) != m_appName) {
    _LOG_ERROR("Action doesn't belong to this application");
    return ActionItemPtr();
  }

  Name deviceName = name.getSubName(0, name.size() - 4);

  _LOG_DEBUG("From [" << name << "] extracted deviceName: " << deviceName << ", sharedFolder: "
                      << sharedFolder
                      << ", seqno: "
                      << seqno);

  return AddRemoteAction(deviceName, seqno, actionData);
}
开发者ID:named-data,项目名称:ChronoShare,代码行数:33,代码来源:action-log.cpp

示例6: idString

bool
IdentityCertificate::isCorrectName(const Name& name)
{
  string idString("ID-CERT");
  int i = name.size() - 1;
  for (; i >= 0; i--) {
    if (name.get(i).toUri() == idString)
      break;
  }

  if (i < 0)
    return false;

  string keyString("KEY");
  size_t keyIndex = 0;
  for (; keyIndex < name.size(); keyIndex++) {
    if (name.get(keyIndex).toUri() == keyString)
      break;
  }

  if (keyIndex >= name.size())
    return false;

  return true;
}
开发者ID:PatrickGuo,项目名称:ndn-cxx-master,代码行数:25,代码来源:identity-certificate.cpp

示例7: interest

/**
 * Use /localhost/nfd/rib/register to register the prefix to the faceId.
 * @param prefix The prefix name to register.
 * @param faceId The face ID.
 * @param face The Face which is used to sign the command interest and call
 * expressInterest.
 * @param enabled On success or error, set enabled[0] = false;
 */
static void
registerRoute(const Name& prefix, boost::uint64_t faceId, Face* face, bool* enabled)
{
  // Use default values;
  boost::uint64_t origin = 255;
  boost::uint64_t cost = 0;
  const boost::uint64_t CHILD_INHERIT = 1;
  boost::uint64_t flags = CHILD_INHERIT;

  ndn_message::ControlParametersTypes_ControlParametersMessage parameters;
  for (size_t i = 0; i < prefix.size(); ++i)
    parameters.mutable_control_parameters()->mutable_name()->add_component
      (prefix.get(i).getValue().buf(), prefix.get(i).getValue().size());
  parameters.mutable_control_parameters()->set_face_id(faceId);
  parameters.mutable_control_parameters()->set_origin(origin);
  parameters.mutable_control_parameters()->set_cost(cost);
  parameters.mutable_control_parameters()->set_flags(flags);
  Blob encodedControlParameters = ProtobufTlv::encode(parameters);

  Interest interest(Name("/localhost/nfd/rib/register"));
  interest.getName().append(encodedControlParameters);
  interest.setInterestLifetimeMilliseconds(10000);

  // Sign and express the interest.
  face->makeCommandInterest(interest);
  face->expressInterest
    (interest,
     bind(&processRegisterResponse, _1, _2, enabled),
     bind(&onTimeout, _1, "Register route command timed out.", enabled));
}
开发者ID:jiachenwang,项目名称:ndncon_Ubuntu_NDN_Hackathon2015,代码行数:38,代码来源:test-register-route.cpp

示例8:

bool
RegexComponentSetMatcher::match(const Name& name, size_t offset, size_t len)
{
  bool isMatched = false;

  /* componentset only matches one component */
  if (len != 1)
    {
      return false;
    }

  for (auto& component : m_components) {
    if (component->match(name, offset, len)) {
      isMatched = true;
      break;
    }
  }

  m_matchResult.clear();

  if (m_isInclusion ? isMatched : !isMatched) {
    m_matchResult.push_back(name.get(offset));
    return true;
  }
  else
    return false;
}
开发者ID:qiuhanding,项目名称:ndn-cxx,代码行数:27,代码来源:regex-component-set-matcher.cpp

示例9:

bool
NdnRegexComponentSetMatcher::match(const Name& name, size_t offset, size_t len)
{
  bool isMatched = false;

  // ComponentSet only matches one component.
  if (len != 1)
    return false;

  for (vector<ptr_lib::shared_ptr<NdnRegexComponentMatcher> >::iterator it = components_.begin();
       it != components_.end();
       ++it) {
    if ((*it)->match(name, offset, len)) {
      isMatched = true;
      break;
    }
  }

  matchResult_.clear();

  if (isInclusion_ ? isMatched : !isMatched) {
    matchResult_.push_back(name.get(offset));
    return true;
  }
  else
    return false;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例10:

shared_ptr<Data>
Response::toData()
{
  Name name;
  name.append(m_zone)
      .append(m_queryType)
      .append(m_rrLabel)
      .append(m_rrType);

  if (m_version.empty()) {
    name.appendVersion();
    m_version = name.get(-1);
  }
  else {
    name.append(m_version);
  }

  shared_ptr<Data> data = make_shared<Data>(name);

  if (m_contentType != NDNS_BLOB && m_contentType != NDNS_KEY) {
    data->setContent(this->wireEncode());
  }
  else {
    data->setContent(m_appContent);
  }
  data->setFreshnessPeriod(m_freshnessPeriod);
  data->setContentType(m_contentType);

  return data;
}
开发者ID:named-data,项目名称:ndns,代码行数:30,代码来源:response.cpp

示例11:

inline bool
RegexComponentSetMatcher::match(const Name& name, size_t offset, size_t len)
{
  bool isMatched = false;

  /* componentset only matches one component */
  if (len != 1)
    {
      return false;
    }

  for (ComponentsSet::iterator it = m_components.begin();
       it != m_components.end();
       ++it)
    {
      if ((*it)->match(name, offset, len))
        {
          isMatched = true;
          break;
        }
    }

  m_matchResult.clear();

  if (m_isInclusion ? isMatched : !isMatched)
    {
      m_matchResult.push_back(name.get(offset));
      return true;
    }
  else
    return false;
}
开发者ID:2nd-ndn-hackathon,项目名称:ndn-cxx-logging,代码行数:32,代码来源:regex-component-set-matcher.hpp

示例12: idString

Name
IdentityCertificate::certificateNameToPublicKeyName(const Name& certificateName)
{
  int i = certificateName.size() - 1;
  string idString("ID-CERT");
  for (; i >= 0; i--) {
    if (certificateName.get(i).toEscapedString() == idString)
      break;
  }

  Name tmpName = certificateName.getSubName(0, i);
  string keyString("KEY");
  for (i = 0; i < tmpName.size(); i++) {
    if (tmpName.get(i).toEscapedString() == keyString)
      break;
  }

  return tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
}
开发者ID:sanchitgupta05,项目名称:ndn-cpp,代码行数:19,代码来源:identity-certificate.cpp

示例13: d

BOOST_FIXTURE_TEST_CASE(FullName, DataIdentityFixture)
{
  // Encoding pipeline

  ndn::Data d(ndn::Name("/local/ndn/prefix"));
  d.setContentType(tlv::ContentType_Blob);
  d.setFreshnessPeriod(time::seconds(10));

  d.setContent(Content1, sizeof(Content1));

  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  keyChain.sign(d, security::SigningInfo(security::SigningInfo::SIGNER_TYPE_CERT, certName));

  Name fullName;
  BOOST_REQUIRE_NO_THROW(fullName = d.getFullName());

  BOOST_CHECK_EQUAL(d.getName().hasWire(), true);
  BOOST_CHECK_EQUAL(fullName.hasWire(), false);

  // check if name was properly cached
  BOOST_CHECK_EQUAL(fullName.get(-1).value(), d.getFullName().get(-1).value());

  // check FullName content
  BOOST_REQUIRE_EQUAL(d.getName().size() + 1, fullName.size());
  BOOST_CHECK_EQUAL_COLLECTIONS(d.getName().begin(), d.getName().end(),
                                fullName.begin(), fullName.end() - 1);
  BOOST_CHECK_EQUAL(fullName.get(-1).value_size(), 32);

  // FullName should be reset after the next line
  d.setFreshnessPeriod(time::seconds(100));
  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  // Decoding pipeline
  d.wireDecode(Block(Data1, sizeof(Data1)));
  BOOST_REQUIRE_NO_THROW(fullName = d.getFullName());

  BOOST_CHECK_EQUAL(fullName.toUri(),
    "/local/ndn/prefix/"
    "sha256digest=28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548");
}
开发者ID:2nd-ndn-hackathon,项目名称:ndn-cxx-logging,代码行数:41,代码来源:data.t.cpp

示例14: subjectName

shared_ptr<IdentityCertificate>
Pib::prepareCertificate(const Name& keyName, const KeyParams& keyParams,
                        const time::system_clock::TimePoint& notBefore,
                        const time::system_clock::TimePoint& notAfter,
                        const Name& signerName)
{
  // Generate mgmt key
  m_tpm->generateKeyPairInTpm(keyName, keyParams);
  shared_ptr<PublicKey> publicKey = m_tpm->getPublicKeyFromTpm(keyName);

  // Set mgmt cert
  auto certificate = make_shared<IdentityCertificate>();
  Name certName = keyName.getPrefix(-1);
  certName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
  certificate->setName(certName);
  certificate->setNotBefore(notBefore);
  certificate->setNotAfter(notAfter);
  certificate->setPublicKeyInfo(*publicKey);
  CertificateSubjectDescription subjectName(oid::ATTRIBUTE_NAME, keyName.getPrefix(-1).toUri());
  certificate->addSubjectDescription(subjectName);
  certificate->encode();


  Name signingKeyName;
  KeyLocator keyLocator;
  if (signerName == EMPTY_SIGNER_NAME) {
    // Self-sign mgmt cert
    keyLocator = KeyLocator(certificate->getName().getPrefix(-1));
    signingKeyName = keyName;
  }
  else {
    keyLocator = KeyLocator(signerName.getPrefix(-1));
    signingKeyName = IdentityCertificate::certificateNameToPublicKeyName(signerName);
  }

  SignatureSha256WithRsa signature(keyLocator);
  certificate->setSignature(signature);
  EncodingBuffer encoder;
  certificate->wireEncode(encoder, true);
  Block signatureValue = m_tpm->signInTpm(encoder.buf(), encoder.size(),
                                          signingKeyName, DIGEST_ALGORITHM_SHA256);
  certificate->wireEncode(encoder, signatureValue);

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

示例15: output

Blob
Tlv0_2WireFormat::encodeName(const Name& name)
{
  struct ndn_NameComponent nameComponents[100];
  NameLite nameLite
    (nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
  name.get(nameLite);

  DynamicUInt8Vector output(256);
  ndn_Error error;
  size_t dummyBeginOffset, dummyEndOffset, encodingLength;
  if ((error = Tlv0_2WireFormatLite::encodeName
       (nameLite, &dummyBeginOffset, &dummyEndOffset,
        DynamicUInt8ArrayLite::downCast(output), &encodingLength)))
    throw runtime_error(ndn_getErrorString(error));

  return output.finish(encodingLength);
}
开发者ID:,项目名称:,代码行数:18,代码来源:


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