本文整理汇总了C++中Name::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::begin方法的具体用法?C++ Name::begin怎么用?C++ Name::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeNack
shared_ptr<ndn::Data>
NdnDataManager::operator[]( shared_ptr<const ndn::Interest> interest )
{
Name subname = interest->getName();
auto it = subname.end()-1;
while( ( it->isVersion() || it->isSegment()
|| it->isSegmentOffset() || it->isTimestamp()
|| it->isSequenceNumber() ) && ( it-- ) != subname.begin() );
subname = subname.getPrefix( it - subname.begin() + 1 );
if( m_producers.find( subname ) != m_producers.end() )
{
// find data producer
auto producer = m_producers[subname];
// if access level is 0, no access needs to be provided
if( interest->getAuthTag().getAccessLevel() == 0 )
{
Coordinator::
producerSatisfiedRequest( interest->getName().getPrefix( 2 ),
interest->getName() );
return producer->makeData( interest );
}
// generate data packet
shared_ptr<Data> data = producer->makeData( interest );
// check that the interest's access rights
// satisfy the data's requirements
if( m_auth_manager->getTagAccess( interest->getAuthTag() )
< data->getAccessLevel() )
{
Coordinator::
producerDeniedRequest( interest->getName().getPrefix( 2 ),
interest->getName(),
"Insufficient Auth" );
return makeNack( *data );
}
// check that the data satisfies interest
if( interest->matchesData( *data ) )
{
Coordinator::
producerSatisfiedRequest( interest->getName().getPrefix(2),
interest->getName() );
return data;
}
}
Coordinator::producerOther( interest->getName().getPrefix( 2 ),
"No data matching "
+ interest->getName().toUri() );
return NULL;
};
示例2: 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");
}
示例3:
bool
SecRuleRelative::compare(const Name & dataName, const Name & signerName)
{
if((dataName == signerName) && ("==" == m_op || ">=" == m_op))
return true;
Name::const_iterator i = dataName.begin ();
Name::const_iterator j = signerName.begin ();
for (; i != dataName.end () && j != signerName.end (); i++, j++)
{
if ((i->compare(*j)) == 0)
continue;
else
return false;
}
if(i == dataName.end())
return false;
else
return true;
}
示例4:
// 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;
}
示例5: regexStr
shared_ptr<RegexTopMatcher>
RegexTopMatcher::fromName(const Name& name, bool hasAnchor)
{
std::string regexStr("^");
for (Name::const_iterator it = name.begin(); it != name.end(); it++)
{
regexStr.append("<");
regexStr.append(convertSpecialChar(it->toUri()));
regexStr.append(">");
}
if (hasAnchor)
regexStr.append("$");
// On OSX 10.9, boost, and C++03 the following doesn't work without ndn::
// because the argument-dependent lookup prefers STL to boost
return ndn::make_shared<RegexTopMatcher>(regexStr);
}
示例6: 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");
}