本文整理汇总了C++中Name::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::at方法的具体用法?C++ Name::at怎么用?C++ Name::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::at方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: Name
Name
Strategy::makeInstanceName(const Name& input, const Name& strategyName)
{
BOOST_ASSERT(strategyName.at(-1).isVersion());
bool hasVersion = std::any_of(input.rbegin(), input.rend(),
[] (const name::Component& comp) { return comp.isVersion(); });
return hasVersion ? input : Name(input).append(strategyName.at(-1));
}
示例3:
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));
}
}
示例4:
void
Tracer::onReceive(const Name& name)
{
if (m_options.shouldPrintTimestamp) {
std::cout << time::toIsoString(time::system_clock::now()) << " - ";
}
std::cout << "interest received: seq=" << name.at(-1).toUri() << std::endl;
}
示例5: isPrefixOf
bool Name::isPrefixOf(const Name& name) const{
if(size() >= name.size()) return false;
for(std::size_t i = 0; i < size(); i++){
if(at(i) != name.at(i)){
return false;
}
}
return true;
}
示例6: performInnerAliasSearch
SearchResult performInnerAliasSearch(AST::Alias& alias, const Name& name) {
if (name.size() != 1 || name.isAbsolute()) return SearchResult::None();
const auto iterator = alias.namedTemplateVariables().find(name.at(0));
if (iterator != alias.namedTemplateVariables().end()) {
return SearchResult::TemplateVar(*(iterator->second));
}
return SearchResult::None();
}
示例7: performInnerCatchClauseSearch
SearchResult performInnerCatchClauseSearch(AST::CatchClause* catchClause, const Name& name) {
if (name.size() != 1 || name.isAbsolute()) return SearchResult::None();
const auto iterator = catchClause->namedVariables().find(name.at(0));
if (iterator != catchClause->namedVariables().end()) {
return SearchResult::Var(*(iterator->second));
}
return SearchResult::None();
}
示例8: performInnerTypeInstanceSearch
SearchResult performInnerTypeInstanceSearch(AST::TypeInstance& typeInstance, const Name& name) {
if (name.size() != 1 || name.isAbsolute()) return SearchResult::None();
const auto iterator = typeInstance.namedTemplateVariables().find(name.at(0));
if (iterator != typeInstance.namedTemplateVariables().end()) {
return SearchResult::TemplateVar(*(iterator->second));
}
return SearchResult::None();
}
示例9: performInnerFunctionSearch
SearchResult performInnerFunctionSearch(AST::Function& function, const Name& name) {
if (name.size() != 1 || name.isAbsolute()) return SearchResult::None();
// Search template variables.
{
const auto iterator = function.namedTemplateVariables().find(name.at(0));
if (iterator != function.namedTemplateVariables().end()) {
return SearchResult::TemplateVar(*(iterator->second));
}
}
// Search parameter variables.
{
const auto iterator = function.namedVariables().find(name.at(0));
if (iterator != function.namedVariables().end()) {
return SearchResult::Var(*(iterator->second));
}
}
return SearchResult::None();
}
示例10: performTypeInstanceSearch
SearchResult performTypeInstanceSearch(AST::TypeInstance& typeInstance, const Name& name, size_t pos) {
const auto size = name.size() - pos;
if (size == 0) return SearchResult::TypeInstance(typeInstance);
const auto canonicalName = CanonicalizeMethodName(name.at(pos));
const auto function = typeInstance.findFunction(canonicalName);
if (function != nullptr && function->isStaticMethod()) {
return performFunctionSearch(*function, name, pos + 1);
}
return SearchResult::None();
}
示例11:
bool
Name::equals(const Name& name) const
{
if (size() != name.size())
return false;
for (size_t i = 0; i < size(); ++i) {
if (at(i) != name.at(i))
return false;
}
return true;
}
示例12:
int
Name::compare(size_t pos1, size_t count1, const Name& other, size_t pos2, size_t count2) const
{
count1 = std::min(count1, this->size() - pos1);
count2 = std::min(count2, other.size() - pos2);
size_t count = std::min(count1, count2);
for (size_t i = 0; i < count; ++i) {
int comp = this->at(pos1 + i).compare(other.at(pos2 + i));
if (comp != 0) { // i-th component differs
return comp;
}
}
// [pos1, pos1+count) of this Name equals [pos2, pos2+count) of other Name
return count1 - count2;
}
示例13: performNamespaceSearch
SearchResult performNamespaceSearch(AST::Namespace& nameSpace, const Name& name, size_t pos) {
const auto size = name.size() - pos;
if (size == 0) return SearchResult::None();
const auto iterator = nameSpace.items().find(name.at(pos));
if (iterator != nameSpace.items().end()) {
const auto& item = iterator->second;
if (item.isFunction()) {
return performFunctionSearch(item.function(), name, pos + 1);
} else if (item.isNamespace()) {
return performNamespaceSearch(item.nameSpace(), name, pos + 1);
} else if (item.isAlias()) {
return performAliasSearch(item.alias(), name, pos + 1);
} else if (item.isTypeInstance()) {
return performTypeInstanceSearch(item.typeInstance(), name, pos + 1);
}
}
return SearchResult::None();
}
示例14: if
int
Name::compare(const Name& other) const
{
for (size_t i = 0; i < size() && i < other.size(); ++i) {
int comparison = at(i).compare(other.at(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 (size() < other.size())
return -1;
else if (size() > other.size())
return 1;
else
return 0;
}