本文整理汇总了C++中Name::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::size方法的具体用法?C++ Name::size怎么用?C++ Name::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getExclude
bool
Interest::matchesName(const Name& name) const
{
if (name.size() < m_name.size())
return false;
if (!m_name.isPrefixOf(name))
return false;
if (getMinSuffixComponents() >= 0 &&
// name must include implicit digest
!(name.size() - m_name.size() >= static_cast<size_t>(getMinSuffixComponents())))
return false;
if (getMaxSuffixComponents() >= 0 &&
// name must include implicit digest
!(name.size() - m_name.size() <= static_cast<size_t>(getMaxSuffixComponents())))
return false;
if (!getExclude().empty() &&
name.size() > m_name.size() &&
getExclude().isExcluded(name[m_name.size()]))
return false;
return true;
}
示例3:
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;
}
示例4: 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;
}
示例5: extendName
static void
extendName(Name& name, size_t length)
{
BOOST_ASSERT(length >= name.size());
for (size_t i = name.size(); i < length; i++) {
name.append("dup");
}
}
示例6: at
bool Name::operator<(const Name& name) const{
if (size() != name.size()) return size() < name.size();
for (std::size_t i = 0; i < size(); i++) {
if (at(i) != name.at(i)) {
return at(i) < name.at(i);
}
}
return false;
}
示例7:
Name::Name(const Name& prefix, const Name& suffix)
: isAbsolute_(prefix.isAbsolute()) {
list_.reserve(prefix.size() + suffix.size());
for(std::size_t i = 0; i < prefix.size(); i++){
list_.push_back(prefix.at(i));
}
for(std::size_t i = 0; i < suffix.size(); i++){
list_.push_back(suffix.at(i));
}
}
示例8: performAliasSearch
SearchResult performAliasSearch(AST::Alias& alias, const Name& name, size_t pos) {
const auto size = name.size() - pos;
if (size == 0) return SearchResult::Alias(alias);
return SearchResult::None();
}
示例9: performFunctionSearch
SearchResult performFunctionSearch(AST::Function& function, const Name& name, size_t pos) {
const auto size = name.size() - pos;
if (size == 0) return SearchResult::Function(function);
return SearchResult::None();
}
示例10: sregex_iterator
bool
InterestFilter::doesMatch(const Name& name) const
{
if (name.size() < prefix_.size())
return false;
if (hasRegexFilter()) {
#if NDN_CPP_HAVE_REGEX_LIB
// Perform a prefix match and regular expression match for the remaining
// components.
if (!prefix_.match(name))
return false;
return regex_lib::sregex_iterator() != NdnRegexMatcher
(regexFilterPattern_, name.getSubName(prefix_.size())).iterator;
#else
// We should not reach this point because the constructors for regexFilter
// don't compile.
throw runtime_error("InterestFilter::regexFilter is not supported");
#endif
}
else
// Just perform a prefix match.
return prefix_.match(name);
}
示例11: 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;
}
示例12: 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);
}
示例13: signData
void
signData(Data& data, Name certificateName = Name())
{
if (certificateName.size() == 0)
certificateName = defaultCertName_;
keyChain_.sign(data, certificateName);
}
示例14: if
int
Name::compare
(int iStartComponent, size_t nComponents, const Name& other,
int iOtherStartComponent, size_t nOtherComponents) const
{
if (iStartComponent < 0)
iStartComponent = components_.size() - (-iStartComponent);
if (iStartComponent < 0)
iOtherStartComponent = other.components_.size() - (-iOtherStartComponent);
nComponents = min(nComponents, size() - iStartComponent);
nOtherComponents = min(nOtherComponents, other.size() - iOtherStartComponent);
size_t count = min(nComponents, nOtherComponents);
for (size_t i = 0; i < count; ++i) {
int comparison = components_[iStartComponent + i].compare
(other.components_[iOtherStartComponent + i]);
if (comparison == 0)
// The components at this index are equal, so check the next components.
continue;
// Otherwise, the result is based on the components at this index.
return comparison;
}
// The components up to min(this.size(), other.size()) are equal, so the
// shorter name is less.
if (nComponents < nOtherComponents)
return -1;
else if (nComponents > nOtherComponents)
return 1;
else
return 0;
}
示例15: 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));
}